This is the error I’m getting:
CS1612: Cannot modify a value type return value of `UnityEngine.Transform.rotation’. Consider storing the value in a temporary variable
Can anyone tell me why this is happening? I’ve been having this issue with several other rotation-changing functions as well. Please and thanks.
The warning message is exactly telling you what to do, so fixing it schould be simple. As to Why.
Rotation is of type Quaternion and a Quaternion is a value type (struct) and not a reference type (class).
Value types are returned by copy. So when you say “Hey whats your rotation” than you are getting a copy of the object and not the actual object back. Modifieing a copy is more or less useless except when you assign the copy back to the rotation.