- Home /
Inconsistent Jump height 3d
I have a script for movement but for some reason the jump segment will never jump the same height each time. public float forwardForce = 2000f; public float sidewaysForce = 500f; public float jumpForce = 100f; // Fixed Update is used when using physics
public void Jump()
{
if (rb.position.y < 1.75)
if(rb.position.y > 0.9)
if (rb.position.x < 7)
if (rb.position.x > -7)
{
rb.AddForce(0, jumpForce * Time.deltaTime, 0, ForceMode.VelocityChange);
}
Answer by aFeesh · Sep 04, 2019 at 03:40 PM
@robbos729 Your jumps are different because you are multiplying by Time.deltaTime
which changes every frame. So the amount of force you are adding is different every jump.
Answer by xAdamQ · Sep 04, 2019 at 03:54 PM
Usually when we make a jump it's on time per button click (one frame) so you don't have to multiply it by deltaTime, just use if(Input.GetKeyDown(KeyCode.urKey)) Jump();
Your answer
Follow this Question
Related Questions
ForceMode.Impulse Doesnt always fire. 2 Answers
rigidbody.Velocity stops gravity 2 Answers
Change rigidbody's jumping speed 2 Answers
How to change velocity of object which move by Rigidbody. 1 Answer