How can I fix crouching issue?,I have problems with crouching
If my player goes under something while crouching and I release the crouch key, my player gets blocked into the wall. I want my player not to stand up if something is above him. Please help!
Answer by tormentoarmagedoom · Feb 20, 2020 at 02:21 PM
Hello.
then you need some kind of "detection object". For example, an empty object child of the player with atrigger collider, over his head
Then a simple script for this detector that is alwys cheking (with OnTriggerStay) if there is some object over your head. IF detects n object and you are crouch, dont let the player stand again, until the script detects nothing.
Do some tests, look for tutorials, etc..! Bye & Good luck!
Firstly, Thanks for the reply. I have been trying to do this with the OnTriggerEnter only, and I failed with that. I didn't know that there are more "OnTrigger" commands aswell. So, you actually helped me to get that information and make the crouching system a succes. I did it with OnTriggerEnter and OnTriggerExit. I appreciate you. Thanks for helping me sir. Have a wonderfull day!
Nice then!
for next class, i recommend you to learn about FixedUpdate (like update fucntion, but is executed before the Ontrigger functions) This way, you can set some variables in FixedUpdate, that can be changed right ater at OnTrigger functions, each frame.
This is good when using Trigger Enter and exit functions is not the solution.
Bye!
Your answer
![](https://koobas.hobune.stream/wayback/20220612223639im_/https://answers.unity.com/themes/thub/images/avi.jpg)