Original Post
🔒 Locked
Jumping
Advertisement
That depends on what kind of game you're making.
For "ballistic" jumps, you typically just keep a "current velocity" and when jumping, you give a pretty hefty kick (impulse) upwards. This will make the current velocity go upwards. Each step, gravity will start pulling the velocity down, until you start to fall, and eventually hit the ground again; then collision will negate the velocity and you're running straight.
For more "stateful" jumps, you probably need to add logic state to your character controller; typically you will add an enum for the controller state ("standing" "running" "jumping" "crawling" etc), and a counter for how many steps since the state started; then the update logic will look at the state and the counter, and figure out what the right action is. (OO fanatics will factor this enum into a polymorphic class.)
For "ballistic" jumps, you typically just keep a "current velocity" and when jumping, you give a pretty hefty kick (impulse) upwards. This will make the current velocity go upwards. Each step, gravity will start pulling the velocity down, until you start to fall, and eventually hit the ground again; then collision will negate the velocity and you're running straight.
For more "stateful" jumps, you probably need to add logic state to your character controller; typically you will add an enum for the controller state ("standing" "running" "jumping" "crawling" etc), and a counter for how many steps since the state started; then the update logic will look at the state and the counter, and figure out what the right action is. (OO fanatics will factor this enum into a polymorphic class.)
Someone should make a completely realistic jumping simulation. Like, given weight-to-muscle ratio, with all kinda other fancy high-techy buzzwordy things thrown in, they should simulate an actual jump.
It really would be cool to simulate me jumping off a building to see whether or not it would hurt. Because throwing your best friend off first isn't *always* an option.
It really would be cool to simulate me jumping off a building to see whether or not it would hurt. Because throwing your best friend off first isn't *always* an option.
well determining whether jumping off a building would hurt is a lot different than creating a jumping simulator, but i assume you were joking. :)
uhh you need to think about all sorts of different things, you really havent given us much information about your game. the most simple way would be to add char or something that defines the current animation of your person, and make one coorespond to the jumping animation. And when you need to accomplish whatever you were trying to do by jumping, you could just have a if(PlayerState & jumping) to see if the person is jumping.
If you have physics acting on your game objects, then this is very easy, just simply add to the players upward velocity and gravity will pull you back down. This is a much more robust solution becuase the positon of the player is different allowing for dodging bullets and jumping over stuff :), but then again you have to write a physics engine :(
uhh you need to think about all sorts of different things, you really havent given us much information about your game. the most simple way would be to add char or something that defines the current animation of your person, and make one coorespond to the jumping animation. And when you need to accomplish whatever you were trying to do by jumping, you could just have a if(PlayerState & jumping) to see if the person is jumping.
If you have physics acting on your game objects, then this is very easy, just simply add to the players upward velocity and gravity will pull you back down. This is a much more robust solution becuase the positon of the player is different allowing for dodging bullets and jumping over stuff :), but then again you have to write a physics engine :(
Quote:
Original post by Boku San
Because throwing your best friend off first isn't *always* an option.
Depending on the building ofcourse, this is only an option the first time ;)
But what hplus0603 said sounds a good solution. Give the character some upward velocity. For animation purposes and to check if the character is already airborne you would need a flag to indicate the character is jumping.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement