//Edit: There is a GIF in here but I don’t know how to show it, open the link instead.

The code is supposed to snap the camera rotation at a right angle to a planet, however it always does it at (0, 0, 0).

public GameObject planet; void SnapCameraToPlanetTangent() { Vector3 pointToCenter = transform.position + planet.transform.position; Vector3 tangent = Vector3.Cross(transform.TransformDirection(Vector3.forward), pointToCenter); float difference = Vector3.Angle(transform.TransformDirection(Vector3.left), tangent); float dot = Vector3.Dot(transform.TransformDirection(Vector3.up), tangent); if (dot < 0) { transform.eulerAngles += new Vector3(0, 0, difference) * Time.deltaTime * rotateSpeed; } else transform.eulerAngles += new Vector3(0, 0, -difference) * Time.deltaTime * rotateSpeed; }

The green ball’s transform is (0,0,0), the white ball is set to “planet”.