Hello friends:
Right now I am making a script that allows objects to move on a fixed radius around a sphere, with arbitrary velocities and rotations. Currently, I am doing this to reorient the object as it flies around the sphere:
var normal: Vector3 = (rigidbody.position - anchor.transform.position).normalized;
var cross : Vector3 = Vector3.Cross(normal, transform.forward);
rigidbody.position = anchor.transform.position + normal * orbitRadius;
rigidbody.rotation = Quaternion.LookRotation(Vector3.Cross(cross, normal), normal);
However, when I add force to this object, the object’s velocity around the sphere slows down over time because the velocity is not reoriented in addition to the rigidbody’s position. Essentially, I believe that the velocity does not stay tangent to the sphere and I need it to. I am wondering how best to accomplish that.
Thanks!