Is there a transform method equivalent to assigning euler angle offsets?
I'm using the following code to modify the pitch and yaw orientation of an object, which is working perfectly as intended:
transform.eulerAngles = new Vector3(
transform.eulerAngles.x + pitch,
transform.eulerAngles.y + yaw,
transform.eulerAngles.z
);
Question: Is there an equivalent way of doing this with a method on the transform?
Here is what I've tried:
transform.Rotate(pitch, yaw, 0);
The above method will still impact the roll (presumably because the rotation is local?)
transform.Rotate(pitch, yaw, 0, Space.World);
This method can still impact all 3 rotation fields, not really sure why though.
Edit:
Just my luck, 5 minutes after posting this I found a solution.
transform.Rotate(pitch, 0, 0);
transform.Rotate(0, yaw, 0, Space.World);
This code performs exactly the same as the euler angle assignment I've been using, but I'm struggling to see why. How is the euler assignment equivalently capturing the relativity of local pitch and global yaw?
Your answer
Follow this Question
Related Questions
Auto level an object 0 Answers
How can I set rotation properly? 0 Answers
Problems With .rotate behavior 1 Answer
How to change rotation for a FirstPersonController through script. 0 Answers