cancel
Showing results for 
Search instead for 
Did you mean: 

How do you set up crouch detection?

Sern_Of_Canada
Honored Guest
Hey everyone, I'm new to coding for vr and relatively new to Unity too. I'm trying to figure out how to implement crouch detection for a host of game functions such as stealth. I want a bool to trigger true when the player reaches a certain threshold when crouching but I am unsure what the best way of going about it is. So far I have my height in a float and a second float that is 0.6 of that number. I am not really sure where to go from here. Not sure what to track to detect how far the headset is above the ground at any given time either. 
2 REPLIES 2

MikeF
Trustee
track the Y axis of the head anchor. If the Y value goes below your threshold value, crouch = true

Sern_Of_Canada
Honored Guest
That should work, thank you!