- Home /
Using RotatedAround twice
Using C#, I have two sliders that should affect the left/right and up/down rotation around an object. Using both of these lines below separately causes what I want to happen.
transform.RotateAround(AroundObject.position, Vector3.up, xAngle);
transform.RotateAround(AroundObject.position, Vector3.right, yAngle);
However, using them both together like above doesn't work if the xAngle is 90, the second RotateAround does nothing. What I want is for the rotation left and right be done by the first one, which works, then the second always rotate up and down, which doesn't work if done together with the first.
I think the problem is the axis I am rotating around (Vector3.right), which doesn't change. I have tried several different things like
new Vector3(transform.position.x, 0, 0)
but that didn't work either. What axis do I have to use to get my desired effect?
Answer by DoctorWhy · Jul 23, 2012 at 09:05 PM
Apparently simply reordering the rotations to first do the up/down rotation, then the left/right rotation, and restricting the up/down rotation to 89 degrees instead of 90 gets the effect that I want. Interesting enough.
Your answer
Follow this Question
Related Questions
RotateAround reversing doesn't work with negative vector3 0 Answers
RotateAround Limitations 2 Answers
Resetting transform's original position and rotation after using transform.rotateAround 1 Answer
Rotate object in the direction where it is going 1 Answer
Rotation promlems past 90 and 270 3 Answers