Im building this game that requires the rotation of an object relative to the camera in 3D space. Essentially, i have an object that is the child of an FPS camera which needs to be rotate in front of the camera acting as a third person character. I’m not interested in using mouseX or Mouse y to do this as I’m developing for VR. Help is greatly appreciated!
I’m programming beginner and someone was helping me and this is what we came up with but it’s not working:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeadMotion : MonoBehaviour {
public GameObject headRotationRoot;
public Quaternion rotationFromTheHead;
public Transform tempTransform;
void Start () {
}
// Update is called once per frame
void Update () {
tempTransform = headRotationRoot.transform;
tempTransform.localRotation = headRotationRoot.transform.localRotation;
transform.localRotation = tempTransform.localRotation;
Debug.Log ("headRotationRoot: " + headRotationRoot.transform.localRotation.x );
Debug.Log ("tempTransform: " + tempTransform.localRotation.x );
Debug.Log ("transform: " + transform.rotation.x);
}
}