Gradually move a Rigidbody (with AddForce) towards a moving position in 3d space


I am creating a arcade-like space game. Right now you can move a spaceship in any direction with standard controls. Pitch, Roll, Yaw, etc. Just like in space there is no drag, but velocity is capped at 100 just for testing. All movement is handled through Rigidbody functions like AddForce, AddRelativeForce, AddRelativeTorque, etc. I have also created a script to simulate gravity between objects. Currently, this only applies to 2 objects. The player and an asteroid object that is denser than it should be testing purposes. I should also add the asteroid is given a random rotation on game start.

The Problem.

I want the player to be able to hit a button (simple enough) and have their spaceship orbit the planet on the same axis as the planet’s rotation at some distance, x, from the planet (very hard it seems). So, basically when you are looking at the object, as you approach this point in space, eventually you will reach a point where you are looking at the same side of the object while orbiting it. Another way to say this would be your orbit reaches parity with the rotation of the planet. Hopefully this description gets the problem across.

I have a video here that can serve as example to simply the problem a little bit. You’ll see 2 objects that I highlight, the first is a GameObject I created as a child of the asteroid, that is the point at which I want my spaceship to move to and then maintain.
I need a way to calculate the forces required to reach that position smoothly. The second object is the asteroid which you can see rotating. The red lines you see are Rays that point towards the asteroid (using it to track the player).

I’ve tried some heavy-handed methods such as setting the position exactly, but this for obvious reasons won’t work. Its instant and the camera stutters. I also tried to Lerp towards the point by changing the Rigidbody position, but this doesn’t work either since it bypasses the physics. If someone has any insights I would be appreciative if you would share. Even just pointing me to right formulas or documentation would be helpful.

I provided my gravity script below, I have this script attached to the top-level player object. All variables with gravity in the name are from the asteroid. The variable rb is the player’s Rigidbody.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LocalGravity : MonoBehaviour
    public Rigidbody gravityTarget;
    public SphereCollider gravityCollider;
    public GameObject gravityOrbitPoint;

    public float gravity = 9.81f;
    public Rigidbody rb;

    public float autoOrientSpeed = 1f;
    public bool autoOrient = false;
    private void Start()
        rb = GetComponent<Rigidbody>();


    private void FixedUpdate()

    private Vector3 diff;

    void ProcessGravity()
        diff = rb.position - gravityTarget.position;
        //Debug.Log("diff: " + diff);
        //Debug.Log("diff leng:" + diff.magnitude);

        rb.AddForce(-diff.normalized * Mathf.Sqrt((gravity * gravityTarget.mass) / diff.magnitude));

        //Debug.Log(Mathf.Sqrt((gravity * gravityTarget.mass) / diff.magnitude));

        if (autoOrient)

        Debug.DrawRay(rb.position, diff.normalized,, 60);

    void Reorient(Vector3 down)
        Quaternion orientationDirection = Quaternion.FromToRotation(-rb.transform.up, down) * rb.transform.rotation;
        rb.transform.rotation = Quaternion.Slerp(rb.transform.rotation, orientationDirection, autoOrientSpeed * Time.fixedDeltaTime);

    void CalculateSphere()
        float sphere = Mathf.Sqrt((gravity * (gravityTarget.mass * rb.mass)) / 1);
        gravityCollider.radius = sphere;