- Home /
How to change distance but maintain speed and height of jump
Suppose I have a block (RigidBody2d) traveling on a flat surface at a constant velocity to the right. The block jumps when the player presses the jump key, and the rigidbody has a force added onto it so that it jumps. What is the best way to change the amount of time that the block spends in the air moving up and "floating" down. E.G. it currently moves 20 units to the right when I press jump before landing, but now I want it to only move 10 units to the right. Additionally, the speed of the block and the jump height of the block should stay the same. The only thing changing is the distance traveled in the air.
Can this be done with the Unity2D physics engine?
Answer by AlwaysSunny · Jun 03, 2015 at 07:15 PM
"Can this be done with the Unity2D physics engine?"
Absolutely!
Will it be "perfect"? Nah. Good enough, probably.
Will it be "easy"? Depends on your familiarity with physics.
You'll be using one or two of the "big four" kinematic equations to arrive at the desired forces. Or, you can use some guesswork and experimentation to dictate how to scale your forces.
This is real, actual physics math. My guess is, the vast majority of games that achieve what you're asking for do not use real physics simulations to do it. Instead, they fake it!
Which approach to recommend depends upon your desired outcome.