- Home /
Float seems to be set to 0 at runtime Oculus Quest
So with having the ability to detect the height of the player in VR, I now am able to use that data in code. This code here grants me a snapshot of the initial player's height at start which will be used in later code.
public Vector3 headPos;
//Constant
public float playerHeightAtStart;
//Variable
public float playerHeight;
public void OnEnable()
{
headPos = head.transform.localPosition;
playerHeight = headPos.y;
playerHeightAtStart = playerHeight;
}
The problem is is that whenever I start the program, playerHeightAtStart is 0 when the playerHeight (continuously being printed) is showing my height. I have tried OnEnable, Awake, and Start and none of them seem to work (I don't know the difference between them so I just tried them for hope), so I think it is my code. I could use a button to set the height or use a timer to grab the height after the runtime has started but I would rather grab the player's height right away.
Thank you for your help!
Edit: Forgive me. For the life of me, I cannot add line spaces to this even if I have done it in a previous post.
Your answer
![](https://koobas.hobune.stream/wayback/20220613013336im_/https://answers.unity.com/themes/thub/images/avi.jpg)