Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class HMDSync : MonoBehaviour
- {
- //This script is to keep rotations of player, camerarig, and camera (head) synced. Only thing is that the camerarig y value should be negative.
- private GameObject CameraHead;
- private GameObject CameraRig;
- private GameObject Player;
- void Start()
- {
- CameraHead = GameObject.Find("Camera (eye)");
- CameraRig = GameObject.Find("[CameraRig]");
- Player = GameObject.Find("Player");
- if (CameraHead && CameraRig && Player != null)
- {
- Debug.Log("All components for HMD Sync found!");
- }
- else
- {
- Debug.Log("Not all components for HMD Sync were found.");
- }
- }
- // Update is called once per frame
- void Update()
- {
- CameraRig.transform.rotation = CameraHead.transform.rotation;
- Player.transform.rotation = CameraHead.transform.rotation;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment