From Game Editor
NOTICE
Make sure you read the Basics of a platformer before going any further.
Jumping
All right so you know the basics of getting the player to jump. But he just doesn't stop. You can keep pressing the button and he will continue to jump. That's highly illogical, and you don't want that. The first thing your going to want to do is create a variable. A variable is really just a way of holding numbers, but you learn more about them later by clicking the link. The type of variable best for this situation is an integer. It is always a whole number (1,3,6,7,-3,-10,ect.) or can't contain decimals. So under player go to collision-> chose top side from the first pull down menu, and ground for the second with repeat off or on (Doesn't matter in this case) choose script editor from the menu. You should be familiar with this window by now, just go ahead and click variables in the bottom left hand corner and choose add. Make the variable "Actor Available" instead of Global, this way it acts on each actor differently. Name it whatever you want so you know what it is, (jump can_jump ect.) and click add. In the following code, the jump variable's name is var, you would replace it with whatever your variable's name is. Now your back in the script editor. All you need here is to put...
var = 1;
where var is the name of the variable you just made (jump can_jump ect.) This will make your variable equal one for the player when he collides on top of the ground actor. Add it as an immediate action. Now head to your jumping script you made earlier.
It should say something along the lines of... KeyDown event -> space (jump)
yvelocity = -10;
what you need to do is to make this only work if your jump variable is equal to one, so you can only jump one time not ∞ times. So put in...
if(var == 0)
{
yvelocity = -10;
var = 0;
}
where var again is the variable you created. If(var == 0) means if the variable is equal to 0 then run the script in the brackes { }. Then reset the var to 0 so you can't jump untill you hit the top of the ground.
And there you go! Now your player can only jump one time!
--Jimmynewguy 17:28, 7 June 2009 (UTC)Jimmynewguy

![[]](/wiki/skins/blender/open.png)