Vector3 newVector = newRotation * oldVector;
Quaternion newQuaternion = newRotation * oldQuaternion;
transform.rotation = newRotation * transform.rotation;
transform.Rotate(0, 0, 30);
transform.LookAt(otherGameObject.transform);
transform.rotation = Quaternion.LookRotation(vector);
There's also Quaternion.FromToRotation for rotating a vector to align another vector
transform.rotation = Quaternion.FromToRotation(transform.up, directionVector);
To slowly rotate towards a target, there are two methods available:
transform.LookAt(Transform target)
does not work, because it aligns the transform.forward
axis towards the target, which is the local transform.right
axis towards the target:transform.right = target.transform.position - transform.position;
(or if you want to use angles:)float angle = Mathf.Atan2(target.transform.position.y, target.transform.position.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
L(lower, upper)
R(lower, upper)
sets the values to a random range, and you can multiply all values at once with +=value