Common Question Regarding Jumping.

Talk about making games.

Common Question Regarding Jumping.

Postby bean59 » Thu Jan 12, 2006 6:14 am

Here is my problem. I have my character set up to jump when space bar is hit. Gravity is set up too. It all works but you can do infinite about of jumps in the air and fly off.

I know there are forums regarding this but I am extremely newb and need an easy explanation on how to disable the space key once he is in the air, and you can only use it once it you touch back down.

What ever methods you have post em because I only have 2 days left until my project is due for school and I REALLY NEED ANYONES HELP! :(
bean59
 
Posts: 1
Joined: Wed Jan 11, 2006 11:12 pm
Score: 0 Give a positive score

Postby Novice » Thu Jan 12, 2006 9:07 am

Create a integer variable canJump.
On Collision with ground canJump=1.
On jump button
Code: Select all
if (canJump==1)
{
yvelocity=-5;
canJump=0;
}
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby DilloDude » Fri Jan 27, 2006 1:09 am

I have experimented with this too, but I discovered that if you have the jump variable change when you jump, you can walk of a platform and then jump in the air. If you are using a draw actor
Code: Select all
yvelocity+=.5
for gravity and a physical response with ground, a collision finish event doesn't work to change the variable to 0. What I have is on collision with any side of ground, change the jump variable to 1 and create a timer for a very short time, about 100 or 200 milliseconds. (I am also trying having a destroy timer before the create timer). Make this event repeat. (make sure you use a different event that dosen't repeat for the physical response. For any other platforms, use the same thing, but make the collision only on the top side, or you can jump constantly up a wall or even along the roof.
Hope people find this useful. 8)
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Novice » Sat Jan 28, 2006 12:00 am

Or you could just do this
Code: Select all
if (player.y>player.yprevious+5) canJump=0;

I havent given much tought about this problem because i havent tried to make a platform game, but i think this should work fine.
The +5 in the code is to make sure that the player isnt just going over some rough terain so it should be changed acording to the bumpines of your terain. I didnt try it out so let me know if it works.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Jokke » Mon Aug 28, 2006 5:56 pm

cant u set the player to jump for certain seconds instead? so after pressing space the character keeps going up untill the time "expires" and then fall to the ground...

dont judge me, im a n00b XD
Image
Jokke
 
Posts: 65
Joined: Sat Aug 26, 2006 11:53 am
Location: Yes
Score: 0 Give a positive score

Re: Common Question Regarding Jumping.

Postby Troodon » Tue Sep 05, 2006 5:46 pm

bean59 wrote:Here is my problem. I have my character set up to jump when space bar is hit. Gravity is set up too. It all works but you can do infinite about of jumps in the air and fly off.

I know there are forums regarding this but I am extremely newb and need an easy explanation on how to disable the space key once he is in the air, and you can only use it once it you touch back down.

What ever methods you have post em because I only have 2 days left until my project is due for school and I REALLY NEED ANYONES HELP! :(


Hi everybody! I don't know if somebody still remembers me. :wink:
I see that these question is very common in game editor forum. Allways there is somebody who asks it. Couldn't there be a tutorial or a forum sticky to pretend it to be always asked again and again?
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby SergeLo00001 » Tue Sep 05, 2006 11:12 pm

there is a tutorial on how to make gravity and how to make ur character jump, but it never shows you how to fix this problem many are having. even playing the tutorial after seeing it you wil notice that you can keep jumping.
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby Troodon » Wed Sep 06, 2006 1:13 pm

I know.
Maybe in the next version ((which is the newest version of game-editor?)) there will be a demo/tutorial that shows the little simple variable trick that disables the jumping before first retouching the ground.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby Game A Gogo » Wed Sep 06, 2006 10:54 pm

just change the variable when he dos a colision on the ground
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby SergeLo00001 » Thu Sep 07, 2006 9:48 pm

explain to me how to do that game a gogo plz
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby Game A Gogo » Thu Sep 07, 2006 11:07 pm

canjump=0;
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Troodon » Sat Sep 09, 2006 7:56 am

Make a variable called 'canjump'.
Then in create actor, make canjump=1.
When you press the jump key, canjump=0.
You can jump only when canjump=1.
When collision with the terrain actor, canjump=1.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby The achievement » Sat Sep 09, 2006 8:56 pm

I had so many problems with this jumping. But i finally got it down,(after so many posts) i used the the solution like DilloDude. i used a timer on when you can jump. but the canJump works very well to. its really not that hard, in fact its very easy. Just takes some time. :D
I am the only Zombie Genocider.
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest