- Home /
Rotate camera to object on sphere
I'm using the MouseOrbit script to rotate a camera around a sphere. I want to add functionality where, if I click on an object that's on the sphere, the camera will rotate and move so that the object is in the center of the camera's view. The camera will still need to be orbiting the sphere at the same distance, with the planet still centered in the camera's view. How can I implement this?
Answer by Detour_Guide · Sep 28, 2017 at 04:57 AM
On a high level you could calculate the vector from the sphere position to the clickable object position to get a direction axis. Move your camera to that axis. This is assuming the sphere's position is based on it's center and the object that is being clicked is at least mostly outside of the sphere. You'll need this.