Problems with jumping
TwilightHunter
Member Posts: 146
Hey, I have a slight issue with my block's jumping. I'm fooling around with the pre-made side-scroller template in GameSalad and have run into a problem. My jumping is set to if "On The Ground" is True, then you may press space bar to jump, which changes "On The Ground" to false. Problem is, (And as cool as it is for some dude with a jet pack) when you run off a cliff without jumping, you can jump in mid-air because "On The Ground" is still true. Is it possible to put in something like... so long as the Player is not colliding with the Ground Actor, "On The Ground" is false? Any help would be great, thanks in advance ;P
Comments
When Actor collides with ground
change attribute - > On the Ground -> True
You hit the jump button
Change the attribute -> On the ground -> false
<Jump functions go here>
and the cycle repeats itself as needed.
@POLYGAMe
That's what I've been doing for a while xD
I did come up with a solution to this problem though. Create an actor 1 pixel less than your actor's width and 1 pixel in height. Mine is 24 wide so I create one that is 23x1. Constrain this to the player's x & y position and then subtract half(adjust if needed) the player height for the y position so it is attached to the bottom of the player's collision box. Now you can do collision checks at the players feet. Since it isn't as wide it won't touch walls or platforms.
So basically now the check would be If the player is Jumping and the Lower collision box is touching the ground then the player is "On The Ground".
Hope this makes sense.
For instance if you look at the platformer example they tag all the physical objects into a tag, so in your collide rule you should be triggering the on ground against anything the player can land on. Hope this makes sense.
If Attribute, (Self) Linear Velocity Y is equal to or less than -1, On The Ground is false.
Now that that's fixed, can anyone tell me which attributes I need to change to make my Player fall faster?