I need a simple script that will track the current rotation of a GameObject.
function Update(){
rotationValue = transform.rotation;
}
The end.
should the variable rotationValue be vector3? i am getting a error can’t convert quaternion to vector3
If you want to see the rotation as a Quaternion:
using UnityEngine;
public class Example : MonoBehaviour {
public Quaternion rotationValue = Quaternion.identity;
void Update(){
rotationValue = transform.rotation;
}
}
If you want to see the rotation as a Vector3:
using UnityEngine;
public class Example : MonoBehaviour {
public Vector3 rotationValue = Vector3.zero;
void Update(){
rotationValue = transform.eulerAngles;
}
}
These are both in C# btw.