Jumping
Author |
Message |
chaos
|
Posted: Thu Aug 04, 2011 3:28 pm Post subject: Jumping |
|
|
I am trying to make a character jump. The problem is I don't know how to go about it? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Ultrahex
|
Posted: Thu Aug 04, 2011 3:45 pm Post subject: Re: Jumping |
|
|
This really depends on what you are making jump, and how realistic you are planning to make it be.
e.g. 2D? 3D? is this a physics simulation? is this for a game? do you have collision detection/response ?
If you just need the player to jump, then just move them up when a button is pressed!
If you need the player to also fall, then just move the player down after moving them up!
Okay, maybe its not that simple...
A simple method of doing so is applying physics to the player.
When the user "jumps" they are applying an acceleration to the player for a very short period of time (resulting in velocity 'upwards'), and then gravity applies acceleration in the opposite direction to make the player fall (resulting in velocity 'downwards').
By adding these two acceleration vectors to velocity, you can a way of jumping; now the actual issues in implementation come...
Since you are now implementing simplistic physics to the players motion, you have to handle collision detection/response of the player with the ground (and possibly with enemies etc) otherwise the player may actually fall through the ground (not a good thing).
If it is just simple 2D flat ground, then we can just check if the players position is below the grounds top, if it is then a collision has occurred, and we need to respond by making the player stay on-top of the ground by changing their 'y' position to be above/on the ground.
Feel free to ask for more details, this information should get you started though! |
|
|
|
|
![](images/spacer.gif) |
|
|