- Home /
How can I increase or decrease jump speed while keeping the jump arc the same?
I'm trying to make a 2D game where there are multiple playable characters. I want each of these characters to have the same arc for their jump, but travel along that arc at different speeds. I understand how to make a character jump using AddForce, and I know you can multiply whatever's inside AddForce by an airSpeed variable, but how can I do all this while keeping the arc of the jump consistent?
Answer by Epsilon_Delta · Jun 01, 2019 at 03:55 PM
Well how would you do this in the real world? You need to either slow time but only locally for your character or fake it with changing the gravity.
So one possible solution is to turn off the default gravity for your rigidbody, apply your own smaller gravity force every PhysicsUpdate and then use smaller jumping force (velocity change) in both x and y direction. This will include some math. Note that if your rigidbody has some drag (or even friction material in some special cases), math can become little bit more complicated and it might be not possible to have exactly the same arc (I am not sure, would have to do the math, but I guess it's true).
Second option that comes to my mind is to use Physics.Simulate() and different physics scenes, but I do not have experience with this since it is pretty new feature. But you can read about it here: https://docs.unity3d.com/ScriptReference/Physics.Simulate.html and you can find some tutorials on Physics scenes on youtube.
Your answer
Follow this Question
Related Questions
How do i stop rigidbody2D bounce 1 Answer
Player Knockback Without Physics 0 Answers
Jump problem 1 Answer
player jumps too high when clicking with two fingers. 2 Answers