(Last updated 21/07/2018)
The player represents your User : its body, its camera, its accessories and controllers. Here we will see how to have some of those parts linked to our trackers positions, and how to network the player movements for a multiplayer game.
Player
Material
Fade : Material in front of the player's eyes to create a blinking effect.
Prefabs
PlayerLight : A simple player prefab example
PlayerLightNetworked : A networked player prefab example using Unity networking
CameraHolder : The player's Camera system with the offset corrections. To be used in the player prefab
Scripts
DisableInputTracking.cs : Disables the headset position tracking system (Oculus, Vive)
VRT_EyeTagOffset.cs : For the camera only. This calculates the position offset between the Tag on the VR headset and the user's eyes position.
VRT_HeadsetRotation.cs : Corrects the camera rotation with the Tag orientation while still using the headset rotation.
VRT_FollowTag.cs : Script to attach on the object that needs to follow the position and rotation.
On the main GameObject, there is no specific script, here we just have the DisableInputTracking script to disable the headset tracking.
The Camera has a VRT_FollowTag script. This script will apply to this GameObject the Tag position and orientation (depending on the box you checked in the script). You can choose the Tag by setting in Tag Type To Follow here the "Head" Tag. That Tag Type is also set when creating the Manager prefab.
Note that here we don't apply the rotation to the Camera. As it will be explained below in "More on the Player Camera", this is because we are using the VR headset rotation directly, not the rotation from the Tag.
On the Gun we follow both rotation and position. Under we have the Gun model that can have an offset position to make sure the Tag is well aligned with the Gun position.
You can have multiple VRT_FollowTag script following the same Tag on different GameObject. For example here we also follow the Head Tag on the player's body mesh, we apply position (except on Y) and just the Y rotation.
To network your player prefab for multiplayer games, we are using Unity Networking (UNet) system. This prefab is based on the standard player prefab to which we had a few script at root :