I’m trying to make my character fall at constant rate (like flappy bird). The problem with gravity is, that it is an acceleration, therefore sometimes jumps are higher than other times, I want jumps to be equal. I tried just changing velocity in FixedUpdate but it doesn’t work as I want, it seems the pull is too strong and changing jump force doesn’t help, it looks glitchy.
void Update()
{
if (Input.GetButtonDown("Jump"))
{
jump = true;
}
}
void FixedUpdate()
{
rb.velocity = new Vector2(forwardVelocity, rb.velocity.y);
if (jump)
{
rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
jump = false;
}
else
{
rb.velocity = new Vector2(rb.velocity.x, -1f);
}
}