Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 5 1 2 3 4 5
Re: Problem with Jump/Fall Code [GER/ENG] [Re: ] #379211
07/30/11 13:57
07/30/11 13:57
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
uhm.. dunno..
but there´s no other way ._.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Jump/Fall Code [GER/ENG] [Re: Espér] #379227
07/30/11 17:06
07/30/11 17:06

M
Malice
Unregistered
Malice
Unregistered
M



Well I found part of the problem and solved it.

This need to be changed
Code:
obj.roofdistframe = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.in_jump == 2)
	{fallstart(obj);}
	else if(obj.in_jump == 3)
	{fallgo(obj);}
	else if(obj.in_jump == 4)
	{landing(obj);}
	else if(obj.roofdistframe > obj.objekthoehe/2 && obj.in_jump != 2 && obj.in_jump != 1)
	{obj.in_jump = 2;}
}



To some thing like this
Code:
switch(obj.in_jump)
	{
		case 2:
		fallstart(obj);
		break;
		case 3:
		fallgo(obj);
		break;
		case 4:
		landing(obj);
		break;
//		default:
//		if(obj.roofdistframe > (obj.objekthoehe) && obj.in_jump != 2 && obj.in_jump != 1)
//		obj.in_jump = 2;
//		break;
	}



The comment out line(in my script),in the original script was causing the "states to rapidly repeat. It in effect was staying in "fallgo" at the last condition. This was happening because you never put a case for 0 so when you reached 0 it defaulted to that line (I think). All I know for sure is that it was changing from in_jump=3 to in_jump=4 then right back to in_jump=3. This made it fall through the floor. So That is fixed, with the setting I'm using now it floats above or touches the floor when it lands. It seems to stop at a different point each time. So I'm trying to figure out why.

I'll work a little more on it.

Re: Problem with Jump/Fall Code [GER/ENG] [Re: ] #379228
07/30/11 17:52
07/30/11 17:52

M
Malice
Unregistered
Malice
Unregistered
M



The sinking into the floor and falling through is so simple to solve. Can't believe I didn't see it before. You have IGNORE_YOU set in the c_move, But right before to c_move, c_trace sets the you entity to the floor below it. So the collision system never activates when it touches the floor. so you stop at once 2 "waits" have finished and the code kills the last c_move. REMOVE IGNORE_YOU for the move or set it to some other object.


Here it is work fine now...
Code:
void landing(ENTITY* obj)
{
	

	obj.fallspeed = obj.fallspeedold;
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe))
	{ 
		obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
		c_move(obj, vector(0, 0, -(1*(bulleter/100))*time_step), nullvector, GLIDE | IGNORE_PASSABLE | USE_POLYGON);
	}
	//obj.z += obj.objekthoehe/2;
	obj.in_jump = 0;
}




void fallgo(ENTITY* obj)
{
	
	
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe))
	{
		c_move(obj, vector(0, 0, -(obj.fallspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON  | GLIDE);
		obj.fallspeed += (obj.gewicht/10.5)*time_step;
		obj.fallspeed = clamp(obj.fallspeed, 0,100);
	}
	else
	{
		if(obj.roofdist <= (obj.objekthoehe) && obj.in_jump != 4)
		{
			obj.in_jump = 4;			
		}
	}
}




void fallstart(ENTITY* obj)
{
	
	obj.jumpspeed = obj.jumpspeedold;
	obj.fallspeedold = obj.fallspeed;
	
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe) && obj.in_jump != 3)
	{
		c_move(obj, vector(0, 0, -(obj.fallspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON  | GLIDE);
		obj.fallspeed += (obj.gewicht/10.5)*time_step;
		obj.jumpkeytrigger = 1;
		obj.in_jump = 3;
		fallgo(obj);
	}
	
}




void jumpgo(ENTITY* obj)
{
	
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z+9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe) && obj.jumpspeed > 10)
	{
		c_move(obj, vector(0, 0, (obj.jumpspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON  | GLIDE);
		obj.jumpspeed -= (obj.gewicht/10.5)*time_step;
	}
	else if(obj.roofdist < (obj.objekthoehe) && obj.in_jump != 2)
	{
		obj.in_jump = 2;
	}
	else if(obj.jumpspeed <= 10 && obj.in_jump != 2)
	{
		obj.in_jump = 2;
	}
	else
	{
		obj.in_jump = 2;
	}
}




void jumpstart(ENTITY* obj)
{
	
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z+9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe) && obj.in_jump != 1)
	{
		obj.jumpspeedold = obj.jumpspeed;
		c_move(obj, vector(0, 0, (obj.jumpspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON  | GLIDE);
		obj.in_jump = 1;
	}
}


//================================================================================================================================================
//================================================================================================================================================
//================================================================================================================================================

void jump_event(ENTITY* obj, var frames, VECTOR* direct, var fall)
{
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z+9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > obj.objekthoehe/2)
	{
		obj.jumpspeedold = obj.jumpspeed;
		c_move(obj, vector(0, 0, (obj.jumpspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON | IGNORE_YOU | GLIDE);
		obj.in_jump = 1;
	}
	while(frames > 0 && obj.in_jump == 1)
	{
		jumpgo(obj);
		c_move(obj, vector((direct.x*(bulleter/100))*time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE | IGNORE_FLAG2);
		
		frames -= 1;
		wait(1);
	}
	
	obj.roofdistframe = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdistframe > obj.objekthoehe/2)
	{obj.in_jump = 2;}
	
	if(fall == true)
	{
		while(obj.in_jump != 0 && obj.in_jump != 1)
		{
			if(obj.in_jump == 2)
			{fallstart(obj);}
			else if(obj.in_jump == 3)
			{fallgo(obj);}
			else if(obj.in_jump == 4)
			{landing(obj);}
			
			c_move(obj, vector((direct.y*(bulleter/100))*time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE | IGNORE_FLAG2);
			wait(1);
		}
	}
	
	c_move(obj, vector((direct.z*(bulleter/100))*time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE | IGNORE_FLAG2);
}




void jump_player(ENTITY* obj)
{
	
	if(key_space == 1 && obj.jumpkeytrigger == 0)
	{
		if(obj.in_jump <= 0)
		{jumpstart(obj);}
		else if(obj.in_jump == 1)
		{jumpgo(obj);}
	}
	else if(key_space == 0 && obj.in_jump == 1)
	{obj.in_jump = 2;}
	else if(key_space == 0 && obj.jumpkeytrigger == 1)
	{obj.jumpkeytrigger = 0;}
	
	obj.roofdistframe = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	switch(obj.in_jump)
	{
		case 2:
		fallstart(obj);
		break;
		case 3:
		fallgo(obj);
		break;
		case 4:
		landing(obj);
		break;
		default:
		if(obj.roofdistframe > (obj.objekthoehe) && obj.in_jump != 2 && obj.in_jump != 1)
		obj.in_jump = 2;
		break;
	}
}




As this is done I will delete your project from my system. Good luck on you project.

Last edited by Malice; 07/30/11 18:52.
Re: Problem with Jump/Fall Code [GER/ENG] [Re: ] #379243
07/30/11 21:57
07/30/11 21:57
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
yeah.. he is not sinking into or falling through the floor.. But it still happens sometimes, that he floats in the air ._.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Jump/Fall Code [GER/ENG] [Re: Espér] #379244
07/30/11 22:00
07/30/11 22:00

M
Malice
Unregistered
Malice
Unregistered
M



Ok the line in landing();
Code:
if(obj.roofdist > (obj.objekthoehe))



try
Code:
if(obj.roofdist >= (obj.objekthoehe))


or
Code:
if(obj.roofdist >= (obj.objekthoehe-5))



that might do it.

Last edited by Malice; 07/30/11 22:01.
Re: Problem with Jump/Fall Code [GER/ENG] [Re: ] #379246
07/30/11 22:05
07/30/11 22:05
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
not really.. and it happens only the 0th or 11th time i jump..


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Jump/Fall Code [GER/ENG] [Re: Espér] #379247
07/30/11 22:16
07/30/11 22:16

M
Malice
Unregistered
Malice
Unregistered
M



CHANGE

Code:
void landing(ENTITY* obj)
{
	

	obj.fallspeed = obj.fallspeedold;
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe))
	{ 
		obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
		c_move(obj, vector(0, 0, -(1*(bulleter/100))*time_step), nullvector, GLIDE | IGNORE_PASSABLE | USE_POLYGON);
	}
	//obj.z += obj.objekthoehe/2;
	

obj.in_jump = 0;
}



TO
Code:
void landing(ENTITY* obj)
{
	

	obj.fallspeed = obj.fallspeedold;
	obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
	if(obj.roofdist > (obj.objekthoehe/2))
	{ 
		obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
		c_move(obj, vector(0, 0, -(1*(bulleter/100))*time_step), nullvector, GLIDE | IGNORE_PASSABLE | USE_POLYGON);
	}
	//obj.z += obj.objekthoehe/2;
if(obj.roofdist<= obj.objekthoehe/2)
{
	obj.in_jump = 0;
}
}



if that doesn't do it I'm out of ideas. Sorry I did my best!

Re: Problem with Jump/Fall Code [GER/ENG] [Re: ] #379248
07/30/11 22:18
07/30/11 22:18
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
k.. now i cnßt jump anymore.. and he is falling really slowly ^^
I´ll take a look into that tomorrow.. it´s late in germany.. i think i´ll quit for today ^^


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Jump/Fall Code [GER/ENG] [Re: Espér] #379249
07/30/11 22:21
07/30/11 22:21

M
Malice
Unregistered
Malice
Unregistered
M



Your Welcome!

Re: Problem with Jump/Fall Code [GER/ENG] [Re: ] #379250
07/30/11 22:34
07/30/11 22:34
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
thanks for your help so far - n8 ^^


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Page 4 of 5 1 2 3 4 5

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1