Character Collisions in VR
Collisions are important in any game be it 2D or 3D, and it’s not much different in VR. Let’s take a look at getting the player to collide with world objects rather than just pass through them.
Character Controller
The Character Controller lives up to it’s namesake and is Unity’s plug and play solution for non-physics based player collisions and movement.
The Unity Documentation states that if you use a Character Controller on an object with an XR origin, it will use the Move function on the Character Controller rather than the typical transform translation.
Character Controller Driver
If you have never used the Character Controller in VR before, this component might be new for you. For the Locomotion Provider assignment, drag and drop the Continuous Move Provider. What this component will do is automatically adjust the height of the Character Controller and Camera to reflect the real world height of the player.
As seen in the Unity documentation below, we can use the Continuous Move Provider as a Locomotion Provider because it is a type of Locomotion Provider.
In play mode you can see the squished Character Controller representing the height of me sitting at a desk with the VR headset on.
Here you can see it auto-adjusting when I press Play.
The player finally collides with the terrain layer, so it’s time to explore!
That’s it for this short article on collisions in VR. Please join me next time as I cover Teleportation Providers and thanks for reading!