RotateAround not working as intended

Hello, I can’t figure out what’s wrong with my code. I use this to rotate my camera in y-axis around screen center (targetPoint) and it works completely fine transform.RotateAround(targetPoint, Vector3.up, scroll * 100 * scrollSensitivity * Time.deltaTime);

But when I do the same thing but with the x-axis it doesn’t work properly transform.RotateAround(targetPoint, Vector3.right, scroll * 100 * scrollSensitivity * Time.deltaTime);

It works fine when the y-axis is unchanged but keeps rotating in that same direction when it’s changed.
Tell me if you don’t understand and I’ll upload pictures to explain more clearly

I understand everything up to this.

what do you mean by ‘y-axis is unchanged’ and what is ‘that same direction’ in this context?

whose transform are you rotating? do you rotate camera directly?
and is the camera at the top of your hierarchy? i.e. do you have nested transforms in the hierarchy?

Yes I’m rotating the camera directly, and it’s on top of hierarchy.


As you see the camera rotates in the same world direction (x-axis) as if it hasn’t changed position after being rotated in y-axis.
I should also mention that the y-axis rotation still works properly after rotating the x-axis like on the lower pictures.

That’s because you’re rotating around the global X-axis via Vector3.right
Try using transform.right instead.

1 Like

Oh I see, thanks a lot!