Rotation in a sphere

Started by
2 comments, last by alvaro 6 years, 3 months ago

I would like the player to be walking inside of a sphere, so the controls of the camera and the movement are relative to the position in the sphere. I already imlemented the gravity but I am having trouble with the rotation and controls of the camera.

explanation.png

Advertisement

(Disclaimer: just woke up)

Looks like what you want is the tangent of the circle at the point where the player is.

This should be just orthogonal to the gravity vector you already have.

Hello to all my stalkers.

I'll make the sphere centered at the origin and with radius 1, for simplicity. Your position on the sphere is a unit-length vector, and your forward direction is another unit-length vector which is perpendicular to the position vector. That's the whole state. It's also handy to have a side direction, which can be computed as the cross-product of the other two vectors. You can move by adding a small multiple of the forward direction or the side direction to the current position. You can then renormalize the position (project back to the surface of the sphere, so you don't walk on a tangent) and use the Gram-Schmidt process to adjust the forward and side vectors.

From the position, forward and side vectors, you should have all you need to set up the camera.

This topic is closed to new replies.

Advertisement