- Home /

# Help with orbit path predictor

I basically want to be able to predict the orbit path which I'm currently finding quite difficult due to all the confusing maths and science equations. I in a sense want to be able to move an orbiting object in a scene and have the orbit prediction path update and show within the scene. This would allow people to make changes to the initial velocity and masses of the objects and see the changed orbital path.

This is my current equation for actually making an object orbit around a target object which i just add the returned value to an AddForce() on the orbiting object's rigid body. This I realized doesn't exactly create a completely perfect orbit, though is quite close.

If someone knows how I could create a funtion that gets the all the positions of the orbiting object each cycle to then be rendered on screen, I'd highly appreciate it.

**Answer** by Major
·
Mar 06 at 07:36 PM

The simplest thing you can do to predict a general trajectory involving some sort of force is going to be Euler's Method.

Euler's Method is used to numerically approximate the solutions to differential equations, and since this is a simulation involving `F = ma`

, this is a reasonable strategy. Since Unity performs physics calculations with some fixed time step (usually 0.02 seconds), using 0.02 as your delta time would work very well for predicting paths.

As far as implementation, you are going to want some initial position and velocity. Using that first position, you can compute where the next position will be after some delta time (dt), by simply doing `initial position + velocity * dt`

. Now add the new position and old velocity to the end of a list. To compute a new point, you're going to want to compute the gravitation acceleration using the last position in your position list. Then with that new acceleration, add it to the last velocity in the list, multiplied by some dt: `v + g * dt`

.

Then you can find a new point by taking the last position in the list, and adding that new velocity times your delta time. You can repeat this process for however many points you need in your prediction.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.