# Predict orbit based on velocity and basic gravity script

So I have my basic planetary gravity script

``````var other : GameObject;

var gravity : float;

var dist : float;

var distSqr : float;

var force : float;

function FixedUpdate()
{
}

{
var dir = (other.rigidbody.position - rigidbody.position);
dist = Vector3.Distance(other.transform.position, transform.position);
distSqr = dist * dist;
force = gravity / distSqr;
}
``````

And it works perfectly fine, the thing is I want to draw the orbit before satellite finish one orbit. I was thinking about putting another object and getting velocity and other variables multiped(for example by 10) but that didnâ€™t work so well. Any help would be appreciated

You can anticipate the path of an object simply getting its equation ahead of time.

Using wikipedia, for projecctile motion:

``````x = initialVelocity * Mathf.Cos(angle) * time;
y = initialVelocity * Mathf.Sin(angle) - 0.5f * gravity * time * time;
``````

Where time is just how long the object has been flying.
time is the value at the moment, time + 1 is the value ahead 1s and then you could plot a point there to show where the guy is going, same with +2 to have even further.

If your object is in ideal condition (no air resistance) then it is fairly simple, with air resistance, it gets trickier since it is based on geometry.

If you need 3D I think the z goes:

``````    z = initialVelocity * Mathf.Sin(angle) * time;
``````

It would be nice if someone with a Phd in physics could confirm that.