Problem rotating a game object on spherical planets when using cinemachine

I have spherical planets where the player runs around. As in any game, i want the player to move in the direction the camera is pointing, so what i tried is to get the local rotation of the camera and paste the “y” component into the player’s rotation. I use local rotation because since the player stands on spheres, it has to be aligned with the center of gravity. My solution creates a positive feedback loop where the player rotates, the cinemachine camera tries to follow the player’s rotation, the camera’s position changed so the player tries to follow it… I’ve been scouting internet but i couldn’t find someone with the same problem regarding spherical worlds and camera controls.

Edit: I use Orbits>Binding mode: Lock to Target so it rotates as the player walks around the sphere.

Any help is greatly appreciated!!!

That’s where the problem is. LockToTarget tells the behaviour to position the camera at the specified offset in target-local space, which will rotate with the player. Try another binding mode, for example WorldSpace or SimpleFollow.

I was using LockOnTarget on purpose so when I walk around the sphere, the camera rotates accordingly with the player. How can i achieve the same without lock on target?

Have a look at the SphericalSurfaceFollow sample scene, it implements what you’re looking for. The key is to use the World Up Override field in the CM Brain. Assign that to the player, and then the camera’s concept of Up will match the player’s.

1 Like