Page 1 of 1

single jump

PostPosted: Sun Jul 01, 2007 1:04 am
by automail10
how do i make my player jump once and not jump in mid-air?

screenshot of test

PostPosted: Sun Jul 01, 2007 2:33 am
by d-soldier
Search the forum and you will find:
http://game-editor.com/forum/viewtopic. ... light=jump

PostPosted: Sun Jul 01, 2007 2:48 am
by automail10
GE keeps saying it is not compatable.
so that dosen't fix that problem.

PostPosted: Sun Jul 01, 2007 2:49 am
by J Maker
add a variable called canJump then on collision with ground
Code: Select all
canJump = 1;
then on keydown have
Code: Select all
if (canJump == 1)
{
    yvelocity=-17;
    canJump = 0;
}
i also have gravty in draw actor of player:
Code: Select all
yvelocity=yvelocity+1;
trust me it works good :D

PostPosted: Sun Jul 01, 2007 2:54 am
by d-soldier
This is exactly what I said in the post I pasted there for you:

The reason he can keep jumping is because the keydown event isn't limited. Heres what you need to do:
1) Click up on SCRIPT menubar, then add an actor variable called "canjump".

2)On your players events, add a collision event (relating to the ground) with a script editor that says:
"canjump = 1;"

3)On your players keydown event (for whatever your jump button is)make the script say:
if(canjump)
{
yvelocity = -8;
canjump=0;
}

4) And that ought to do it! Basically it makes your player only be able to jump if his feet are on the ground. Keep in mind that if you add any other ground objects/platforms/etc. you will need to have that collision event for the player with each of them too.

PostPosted: Sun Jul 01, 2007 2:55 am
by J Maker
oh sry lol :oops: :) :wink: but our gravity codes and jumping is different

PostPosted: Sun Jul 01, 2007 2:58 am
by d-soldier
No not you J, was talking to AutoMail.

PostPosted: Sun Jul 01, 2007 2:58 am
by J Maker
oh sry again im not on top of things today lol :lol:

PostPosted: Wed Jul 11, 2007 5:16 pm
by automail10
i did what you said d- soldier but it still said it wasn't compatatble!

PostPosted: Wed Jul 11, 2007 5:29 pm
by d-soldier
Whoops, I messed up one of the codes... this below is correct. sorry bout that. Re-check to verify that you put these codes where they are supposed to go, and that the variables are spelled correctly without using any capital letters. If you don't remove your other code, it could cause the problem.

1) Click up on SCRIPT menubar, then GLOBAL CODE, then VARIABLES, and add an ACTOR variable called "canjump".

2)On your players events, add a collision event (relating to the ground) with a script editor that says:
"canjump = 1;" (THERE SHOULD ALSO BE A COLISSION/PHYSICAL RESPONSE TO THE GROUND AS WELL)

3)On your players keydown event (for whatever your jump button is)make the script say:
if(canjump==1) //this is the one that was wrong
{
yvelocity = -8;
canjump=0;
}

PostPosted: Wed Jul 11, 2007 6:38 pm
by automail10
ok i'll try it later!

PostPosted: Mon Jul 23, 2007 12:18 am
by automail10
d-soldier wrote:No not you J, was talking to AutoMail.


did you forget the 10? on not the latest post.

PostPosted: Wed Jul 25, 2007 5:59 am
by arcreamer
im starting to understand this scripting but the code was

if (canJump == 1)

why are there 2 equal signs?? :P

PostPosted: Wed Jul 25, 2007 6:03 am
by DilloDude
Use two equals signs (==) to compare to variables. Use a single equals sign (=) to set a variable.

PostPosted: Wed Jul 25, 2007 6:21 am
by arcreamer
thanks!