Hi!
Im trying to implement crouching into my game.
So far I’ve managed to create a working crouch function but I can see problems with it.
How it works now:
The player checks if it’s inside a trigger with a certain tag or not and then force the player to crouch if so.
The problem:
I need to add triggers under every crouch obstacle. If I miss one it could cause problems.
What I want to do:
Add a secondary collider to the player, make it a trigger and have it check if it is inside a object or not and from there force crouch.
This sounds reasonable if you want auto-crouch essentially, which would be an upper-body-area trigger on the player that activates the crouch mode whenever it is touching some geometry.
You will probably need to use layers to avoid the player crouching because he is touching his own normal collider, etc.
Yes, I managed to do that however just turning it into a trigger wont give me the effect I want. My character only detect if he is inside a trigger, not if his trigger is inside a object.
What about raycasting upwards from the floor contact point of the player, raycasting up just enough to detect a low ceiling,and using that as your decision to crouch?