OrbitCamera Problem

Hello there!

I’m having a problem to orbit my camera when it is pointed topdown.

With the OrbitCamera Script when it is pointing forward, it’s easy to orbit sideways and up and down, however, when the camera get to the maximum top point of it’s imaginary sphere, it’s only possible to orbit on it’s “X” and roll in Y and Z…
Considering that the Z is pointing down, is it possible to orbit on Y?

Thanks!

The Mouse Orbit script can’t do this, but you might be able to implement it yourself. You just need to use the camera’s local axes as the rotation axes (so you would use transform.up when you want to move left/right). However, this will cause problems if the camera has to align with the ground again. It is really only suitable when the target object is “floating” in space and the orientation of the camera doesn’t really matter.

Thanks Andeeee,

the solution I’ve found, is to instead of using the mouse orbit orientation for the camera, use the transform.LookAt with the world orientation to forward, like this:

transform.LookAt(target, Vector3.forward);

And that did the trick. If someone else intend to create a script like this, I recommend to check the critical areas of the sphere (like those near zero or 180 in the axes) and change the world orientations accordingly.

Thanks again!