Double jump

Posted By: GameScore

Double jump - 04/12/09 15:38

did someone know how can i realize a double jump with this code?

Code:
	if (key_space)
{
if (distance_to_ground < 2)
{
distance_to_ground = 1;
player_dist.z = 5;
}
}

if (distance_to_ground > 0)
{
			
if (player_dist.z < (distance_to_ground * -1))
{
player_dist.z = distance_to_ground * -1;
				
}
}
else
{			
player_dist.z = -1 * distance_to_ground;
}

Posted By: DiegoFloor

Re: Double jump - 04/12/09 22:13

I don't understand what your code does. What is the role of this player_dist vector?
Posted By: GameScore

Re: Double jump - 04/13/09 06:44

VECTOR player_dist is for move the player along the x,y and z axis
and distance to the ground is
c_trace(vec1_from, vec1_to, IGNORE_ME|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_SPRITES|USE_BOX);

vec1 means
vec_set(vec1_from,my.x);
vec_set(vec1_to,my.x);
vec1_to.z -= 500;
Posted By: DiegoFloor

Re: Double jump - 04/13/09 14:43

Ok. Are you executing a function with this vec_dist that displaces the character in z? Or are you using it directly, like: my.z = vec_dist.z; ? The later isn't a good solution, because when hitting space the player will automatically be at 5 quants above.

The reason I'm asking is that, to do the double jump, the code got to ask in what point of the jump the player is. If it's in the top of the jump AND pressing space_key then increase z speed. Something like that..

I still don't understand what you're doing.
Posted By: GameScore

Re: Double jump - 04/13/09 16:06

this code i have from the lite-c kingdom heart movement code
works very well
you can find it here

http://www.coniserver.net/wiki/index.php/Modified_Kingdom_Hearts_Movement
Posted By: DiegoFloor

Re: Double jump - 04/14/09 01:07

Right! I get it now :]

There are probably several ways to do this, but I can't think of any great solution. You could do something like this:
when jumping keep checking move_to_vector.z (this is the speed in z and is constantly being decreased during the jump), when is arond 0 (move_to_vector.z<0.5 && move_to_vector.z>-0.5 , for example) it means it's close to the highest point, then check for key_space again. If space is pressed then move_to_vector = 5 (or something)

The code should look something like this:
if(move_to_vector.z<0.5 && move_to_vector.z>-0.5)
{
if(key_space) move_to_vector.z = 5;
//this is sloppy. Try to come up with a way to know if the player just hit
//space. Or else he could just keep pressing space from the beginning of the
//jump and still be able to double jump.
}
Posted By: GameScore

Re: Double jump - 04/15/09 21:40

ok, i will try to find a way like your idea
© 2024 lite-C Forums