- Home /
Rotating horizontally around a sphere
Hi, I am using a Faux gravity system with a camera looking down upon an invisible character controller on the sphere's surface. There is a script that gets the camera to follow the controller and the controller can be moved using the arrow keys with left and right changing its position and not its rotation.
The problem I am having is that if the controller os positioned near the top of the sphere, upon moving it sideways it will move closer to the sphere's southern pole. What I am trying to achieve is to have the controller move purely horizontally along the sphere when moving it sideways. In other words, I need the distance between the character controller and the northern or southern pole of the sphere to remain the same when moving left and right. I have tried to use a dot product to help with the rotation of the controller for this but to no avail.
Could anybody help?
Answer by Wolfram · May 31, 2012 at 09:47 AM
You mean the "latitude" of your controller should stay constant when moving left/right? In this case rotate the controller around the "up" axis of the sphere (the axis going through both north and south pole).
Yes, you can. Although it somewhat depends on the rest of your setup, and how else you are controling/modifying your camera and/or character controller. For example, if you control your character via Rigidbody's AddForce etc., the independent RotateAround might not the best approach.