private void Move() { MyRigidbody2D.AddForce(this.direction * speed); if (MyRigidbody2D.velocity == Vector2.zero) { TurnAround(); } }
public void Move(float horizontalMove, float verticalMove) { if (!Attacking && !OnLadder) { MyRigidbody2D.velocity = new Vector2(horizontalMove * movementSpeed, MyRigidbody2D.velocity.y); AnimationManager.SetMovementSpeed(horizontalMove); if (horizontalMove > 0 && !FacingRight || horizontalMove < 0 && FacingRight) { Flip(); } } if (OnLadder) { MyRigidbody2D.velocity = new Vector2(0f, verticalMove * climbSpeed); if (OnGround && horizontalMove != 0) { OnLadder = false; } if (OnGround) { AnimationManager.SetClimbSpeed(0f); } else { AnimationManager.SetClimbSpeed(verticalMove); } } if (!OnGround && MyRigidbody2D.velocity.y < 0) { AnimationManager.StartLand(); } if (OnGround && Jumping) { Jumping = false; MyRigidbody2D.AddForce(new Vector2(0, jumpForce)); } if (Digging) { AnimationManager.Dig(); } if (Blocking) { shieldCollider.enabled = true; } else { shieldCollider.enabled = false; } }