Guest User

Untitled

a guest
Apr 19th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class HMDSync : MonoBehaviour
  5. {
  6.  
  7.     //This script is to keep rotations of player, camerarig, and camera (head) synced. Only thing is that the camerarig y value should be negative.
  8.  
  9.     private GameObject CameraHead;
  10.     private GameObject CameraRig;
  11.     private GameObject Player;
  12.  
  13.     void Start()
  14.     {
  15.         CameraHead = GameObject.Find("Camera (eye)");
  16.         CameraRig = GameObject.Find("[CameraRig]");
  17.         Player = GameObject.Find("Player");
  18.  
  19.         if (CameraHead && CameraRig && Player != null)
  20.         {
  21.             Debug.Log("All components for HMD Sync found!");
  22.         }
  23.         else
  24.         {
  25.             Debug.Log("Not all components for HMD Sync were found.");
  26.         }
  27.     }
  28.  
  29.     // Update is called once per frame
  30.     void Update()
  31.     {
  32.         CameraRig.transform.rotation = CameraHead.transform.rotation;
  33.         Player.transform.rotation = CameraHead.transform.rotation;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment