I don't know what's the cause of this but here's my code occasionally that force gets multiplied 3x causing my character to go off screen.
private void FixedUpdate() {
if (gamOver)
return;
if (onGround && (Input.GetAxis("Jump") > 0)) {
myAnim.SetBool("onGround", false);
myRB.AddForce(new Vector2(myRB.velocity.x, jumpForce));
}
}
I'm doing this on a rigidbody2d. I don't know what I'm doing wrong.
↧