(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.

Package Overview

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.

Player prefab content

On the main GameObject, there is no specific script, here we just have the DisableInputTracking script to disable the headset tracking.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e93ba475-d9d3-428e-b6ee-69a8f6245eda/Capturedecran2018-04-19a22.10.01.png

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.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2a23c1d3-28e7-4e60-9acf-3dce7ecab92a/Capturedecran2018-04-19a22.18.03.png

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.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b71ec747-2c8d-4670-a355-2ba223e00888/Capturedecran2018-04-19a21.28.55.png

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.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/28385a72-8f92-4db9-80fe-90696170011d/Capturedecran2018-04-19a22.11.26.png

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.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ac574a2c-baf6-4fe1-86f5-efffb1e4c989/Capturedecran2018-04-19a22.09.16.png

Networked Player prefab

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 :