Hi, i am new in unity and i am currently following this tutorial by brackeys : 2D Movement in Unity (Tutorial) - YouTube
i can succesfully move, Jump, But there is a problem where when my character tries to crouch, it doesn’t stop crouching, i have set my “crouch” input in unity to “w” and “down” and i also have checked the “GroundCheck” and the “CeilingCheck”. So i dont know what is the problem. Here is the code
public CharacterController2D controller;
public float runSpeed = 40f;
bool jump = false;
bool crouch = false;
public float horizontalMove = 0f;
// Update is called once per frame
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
if (Input.GetButtonDown("Jump"))
{
jump = true;
}
if (Input.GetButtonDown("Crouch"))
{
crouch = true;
} else if (Input.GetButtonDown("Crouch"))
{
crouch = false;
}
}
void FixedUpdate ()
{
controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
jump = false;
}
}