public void HandleJump() { if (IsGrounded && CanMove) { Anim.SetTrigger("mountJump"); RBody2D.velocity = new Vector2(RBody2D.velocity.x, 0); RBody2D.AddForce(new Vector2(0, JumpForce)); HasDoubleJumped = false; } else if (CanDoubleJump && !HasDoubleJumped && CanMove) { RBody2D.velocity = new Vector2(RBody2D.velocity.x, 0); RBody2D.AddForce(new Vector2(0, JumpForce)); HasDoubleJumped = true; } }
public void HandleJump() { if ((IsGrounded || _isFlying) && CanMove) { Anim.SetTrigger("mountJump"); RBody2D.velocity = new Vector2(RBody2D.velocity.x, 0); RBody2D.AddForce(new Vector2(0, JumpForce)); HasDoubleJumped = false; } else if (CanDoubleJump && !HasDoubleJumped && CanMove) { RBody2D.velocity = new Vector2(RBody2D.velocity.x, 0); RBody2D.AddForce(new Vector2(0, JumpForce)); HasDoubleJumped = true; _isFlying = true; RBody2D.gravityScale = 0; Anim.SetBool("isFlying", true); } }