Hi, I was trying to make a random rotation in z axis, I saw something about Euler Angles, Quaternions and Slerp but I have no idea of where to start, I hope you can help me. thanks.
Unity uses quaternions to represent rotation internally. It’s sometimes difficult to work with quaternions directly, so there are helper functions to translate to/from Euler angles, which people usually find more intuitive.
For example, you could read the Euler rotation, assign a random value to one axis, and then assign a new rotation based on that:
function Start() {
var euler = transform.eulerAngles;
euler.z = Random.Range(0.0, 360.0);
transform.eulerAngles = euler;
}
For more information, you can check out the Quaternion class in the scripting doc.