Monday, January 2, 2017

physics - How to make a character in a Box2D world jump faster?


I have a question about using Box2D to simulate a physics-platformer. I manage to make the character move to the right and left, and jumping as well. However, jumping seems extremely slow when compared to most tile-based platformers.


Is there a way to speed up the jumping and falling of the player? I of course know from my basic physics lessons that 'heavier' objects don't fall faster in the real world, but is there a way to simulate this in Box2D?




Answer



You're likely simulating some kind of upward force greater than gravity to make the physics object "jump". Increasing the amount of force will allow the character to reach a higher velocity quickly. Likewise, increasing the force of gravity on the player will make them fall faster.


You can either increase gravity for the entire world, or apply an additional constant force to the player to simulate increased gravity.


Make sure you also increase the jump force when you increase gravity to allow the jump force to overcome the increase in gravity.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...