Question by
twisteminds · Sep 06, 2019 at 02:28 AM ·
collisioncrouch
Crouching collisions
I got my 2D platforming character to crouch and keep them from standing up while under a platform, but they stay crouched until I press the crouch button again. I'm trying to make it so when they move out from under a platform, they will stand up automatically, but I'm not sure how to get it to keep checking for collisions.
if (Input.GetButtonDown("Crouch") && grounded)
{
crouch = true;
anim.SetBool("Crouch", crouch);
speedMod = crouchSpeed * maxSpeed;
crouchCollider.enabled = false;
}
if (Input.GetButtonUp("Crouch"))
{
if (!Physics2D.OverlapCircle(ceilingCheck.position, ceilingRadius, whatIsGround))
{
crouch = false;
anim.SetBool("Crouch", crouch);
speedMod = maxSpeed;
crouchCollider.enabled = true;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612211751im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Detecting collisions on an invisible grid 0 Answers
Collision issue, Plz help 1 Answer
Unity 5: AddForce Increases power when already being pushed towards a collider. How to make stop? 1 Answer
OnTriggerExit not working 0 Answers
Movement causing infinite loops in OnTriggerEnter and OnTriggerExit. 1 Answer