single jump

Non-platform specific questions.

single jump

Postby automail10 » Sun Jul 01, 2007 1:04 am

how do i make my player jump once and not jump in mid-air?

screenshot of test
Attachments
j example.jpg
the example
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Postby d-soldier » Sun Jul 01, 2007 2:33 am

Search the forum and you will find:
http://game-editor.com/forum/viewtopic. ... light=jump
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby automail10 » Sun Jul 01, 2007 2:48 am

GE keeps saying it is not compatable.
so that dosen't fix that problem.
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Postby J Maker » Sun Jul 01, 2007 2:49 am

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
Some people believe Chuck Norris evolved from a dinosaur, the Chucknorisaurus.
----------------------------------------------------------------------------------
Chuck Norris doesn't sleep, he waits.
----------------------------------------------------------------------------------
Chuck Norris doesn't hunt, he kills.
----------------------------------------------------------------------------------
Chuck Norris once shot down a german fighter plane with his finger by yelling BANG!!!
----------------------------------------------------------------------------------
User avatar
J Maker
 
Posts: 177
Joined: Fri Jun 22, 2007 4:17 pm
Location: in the stick version of Hyrule
Score: 10 Give a positive score

Postby d-soldier » Sun Jul 01, 2007 2:54 am

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.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby J Maker » Sun Jul 01, 2007 2:55 am

oh sry lol :oops: :) :wink: but our gravity codes and jumping is different
Some people believe Chuck Norris evolved from a dinosaur, the Chucknorisaurus.
----------------------------------------------------------------------------------
Chuck Norris doesn't sleep, he waits.
----------------------------------------------------------------------------------
Chuck Norris doesn't hunt, he kills.
----------------------------------------------------------------------------------
Chuck Norris once shot down a german fighter plane with his finger by yelling BANG!!!
----------------------------------------------------------------------------------
User avatar
J Maker
 
Posts: 177
Joined: Fri Jun 22, 2007 4:17 pm
Location: in the stick version of Hyrule
Score: 10 Give a positive score

Postby d-soldier » Sun Jul 01, 2007 2:58 am

No not you J, was talking to AutoMail.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby J Maker » Sun Jul 01, 2007 2:58 am

oh sry again im not on top of things today lol :lol:
Some people believe Chuck Norris evolved from a dinosaur, the Chucknorisaurus.
----------------------------------------------------------------------------------
Chuck Norris doesn't sleep, he waits.
----------------------------------------------------------------------------------
Chuck Norris doesn't hunt, he kills.
----------------------------------------------------------------------------------
Chuck Norris once shot down a german fighter plane with his finger by yelling BANG!!!
----------------------------------------------------------------------------------
User avatar
J Maker
 
Posts: 177
Joined: Fri Jun 22, 2007 4:17 pm
Location: in the stick version of Hyrule
Score: 10 Give a positive score

Postby automail10 » Wed Jul 11, 2007 5:16 pm

i did what you said d- soldier but it still said it wasn't compatatble!
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Postby d-soldier » Wed Jul 11, 2007 5:29 pm

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;
}
Last edited by d-soldier on Wed Jul 11, 2007 7:41 pm, edited 1 time in total.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby automail10 » Wed Jul 11, 2007 6:38 pm

ok i'll try it later!
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Postby automail10 » Mon Jul 23, 2007 12:18 am

d-soldier wrote:No not you J, was talking to AutoMail.


did you forget the 10? on not the latest post.
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Postby arcreamer » Wed Jul 25, 2007 5:59 am

im starting to understand this scripting but the code was

if (canJump == 1)

why are there 2 equal signs?? :P
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby DilloDude » Wed Jul 25, 2007 6:03 am

Use two equals signs (==) to compare to variables. Use a single equals sign (=) to set a variable.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby arcreamer » Wed Jul 25, 2007 6:21 am

thanks!
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest