0
\$\begingroup\$

I'm trying to rotate the camera around the view point of the camera. So when the user looks at a build the camera rotate around that building. But the camera does not need to have the building to rotate around. So therefore I want a camera that can rotate around his own point of view. So that the camera behave everywhere the same in the game.

How can I achieve this in Unity 5.6?

\$\endgroup\$
-1
\$\begingroup\$

The answer you're looking for is Arcball rotation, similar to the rotation button in the scene view.

There's a pretty good answer (though related to OpenGL and not Unity) here:

How can I orbit a camera about it's target point?

A cursory search for Arcball rotation with Unity doesn't net any specific code examples, that I could find, though the accepted answer in the above link is a great jumping off point.

\$\endgroup\$
-1
\$\begingroup\$

I would create a Transform variable and set it to the building's center point. Then rotate the camera around it depending on the mouse input.

\$\endgroup\$
  • \$\begingroup\$ Except the OP clearly stated that there isn't always a building to rotate around, which I'm extrapolating to mean the camera needs to rotate around a point in space rather than a specific object, hence my answer regarding Arcball rotation (which is typically for rotating an object, but can also be used to rotate the camera around a set point in space). \$\endgroup\$ – Jesse Williams Jun 5 '17 at 15:09
  • \$\begingroup\$ Err, maybe not a "set point" in space, but around it's currently targeted view. \$\endgroup\$ – Jesse Williams Jun 5 '17 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.