This past week, I converted another puzzle to work in Virtual Reality. I also added some more movement types to help us decide which works best.
So, when i created this puzzle it had a lot of moving parts. Putting it into virtual reality makes a bit easier from a code perspective. To make the rocks interactable and movable, I added a couple of things to them.
The first was a Interactable component and the second was a Throwable component, both from the SteamVR package.
I also changed some of my code. Before, the puzzle was played by having the player pickup a rock and then placed using a raycast.
Now, the rocks can be moved around as the player wants. Which means I need to allow the rocks to be removed from the totem. The way I did this, was to use the OnCollisionStay() and OnCollisionExit() functions within Unity.
Another thing I did this week, was create additional movement types.
I firstly added in the option to chose how you rotate the view. This being either via snap rotation or smooth rotation. Both of these options uses the joystick on an Oculus Touch or the touch pad on the HTC Vive.
The second, was to add in the artificial locomotion to the game. This movement would change the position of the player based on input from a joystick. I added this movement so that I could try it out for myself.
The third, was to add in the teleportation method available within the SteamVR package. To make it work I duplicated the floor plane, and added the teleportation area scrip to it.
Finally, I created a menu for selecting the movement type using the SteamVR button prefab. This menu can be shown by pressing the ‘Y’ button on the Oculus Touch controller, but the binding for the Vive is yet to be set.
You can see the result of both the new movement and updated puzzle in the video below