Trajectory path that gets updated from other gravity sources

I am creating a solar system simulation, where I need the trajectory path to get updated from other gravity sources than from the objects that I am applying it to. That means that I will be able to see the object’s orbits.

I have been looking on different threads and videos, but I have not found something that quite works. Help is greatly appreciated.

I saw a bunch of solar system tutorials on Youtube just now, but perhaps they don’t include the actual gravity calculations you seek.

What you’re looking for is something called the “three body problem” in gravity. It applies to any number of mutually attracting bodies and you can approximate it using discrete physics simulations such as those on a computer. Google around for the limitations and caveats as far as stability.