In this example, I want to rely on gravity with collision capsules to constrain the camera to the ground.
But because of the collision capsule, it prevented me from squatting in the VR mode headset.
To solve this problem, I tried setting the dynamic capsule height dynamically.
See line 96 of the code.
When you change 0.49751244017146684 to another value, the height of the collision capsule accumulates or decreases as the camera moves.
I would like to know why its value is not 0.5 but 0.49751244017146684, can anyone answer for me.
Feels like a javascript floating point arithmetic precision issue. When you say “when the camera moves” , do you mean the movement WebXR feature?
Can I ask - how did you get this wonderful value? I mean, why not 0.49? or 0.497?
See here, moving the xrCamera with the joystick, he will change position.y under the influence of gravity and collision capsule, and this console outputs a value of 0.49751244017146684 when position.y no longer changes.
This is because of javascript’s math precision. Sadly no way around it. You will simply need to compensate correctly. I would assume 0.4975 would work the same.
It is a combination of different matrix computations, inversions, and two babylon components (the collision system and the movement support for webxr).
Maybe using a physics engine instead would provide you with better experience, instead of the internal collision system