I'm currently working on a simple 2d jump and run game. I want to move my player with physics (using addforce).
In the editor, my player jumps at a normal height. But when i build the game it suddenly jumps way higher. I put everything in fixedUpdate() and don't know where the problem is?
//Movement
rb.velocity = new Vector2(horizontalMove, rb.velocity.y);
//Jump
if (jumpPressed)
{
if (isGrounded)
{
rb.AddForce(new Vector2(0f, jumpForce), ForceMode2D.Impulse);
anim.SetTrigger("takeOf");
}
}
Dan
If jumpPressed is true for every frame when the jump key is held, this could be the issue. This would mean that the code could act several times, reapplying the upwards force several times (before it goes far away enough from the ground that the ground check does not detect it). If this is the case, it can be fixed by: