# Calculating an orbit and approach velocties

I have drones in my game that need to approach and orbit a node and shoot at it. Problem is I want to stay away from a real physics simulation, meaning I don't want to give the node and drone a mass and the drone's thrusters' a force. I just want to find the best way to approach and then enter orbit. There was a pretty good answer about using bezier curves and doing it that way, but that is essentially a tween between two fixed points. The nodes are also moving as the drones enter orbit.

-
I am using velocity and acceleration though. – Mob Apr 3 '12 at 23:57
So you don't want to use mass and force, but you do want an acceleration-controlled curve (i.e. C2 continuous) that describes the movement of the drone? – John Calsbeek Apr 4 '12 at 1:49
Yes, I want to a use a fake physics engine basically. Accelerate to a maximum speed, but no friction, mass, etc. – Mob Apr 4 '12 at 2:37
You can't use the Bezier approach out of the box if you plan to have moving node (i.e. the target you want your drone to orbit around). If the node is static in your scene dynamics-wise, you can easily compute a bezier arc with 4 control points and then move on a circle. If your target node has a transport velocity and no acceleration, you can use that transport velocity and add it to your otherwise static Bezier path or circular arcs and still get where you want. If accelerations are involved, you need to incorporate those too. In the end, you're better using a simplistic Euler step. – teodron Apr 4 '12 at 11:41

Remember that, at least in terms of gravitational pull (and not, say, collision), mass is only necessary to determine gravitational strength, and that is only necessary to determine acceleration of other objects toward the mass. And force is only necessary to determine acceleration, which is already known/calculated in this situation.

Thus, it's fairly straightforward to "fake" physics without doing a complicated simulation. You only need to alter acceleration of the drone to "fake" the gravity of the node.

The drone's acceleration (that is self-applied) should be altered by an acceleration vector before being applied to the velocity/position according to the direction of the node and the distance to the node. The direction of the acceleration vector is the direction of the node, and the magnitude is the inverse of the distance. This would simulate the gravitational pull of the node, as drones would be pulled faster towards nodes the closer they are.

The drone must, of course, change its orientation (and thus, acceleration) towards the orbit it wishes to establish (but this is a tangential AI concern). However, if no orbit was desired, this system would even fake the gravitational pull nodes would have on drones that are trying to fly away from them.

The specific algorithm for the acceleration depends on the implementation specifics, such as the drone accelerations and velocities. Testing with a simple run-time input can allow you to quickly determine the acceleration needed to get the right "feel".

This would even result in an eventual circular orbit, as long as the drone continually accelerates itself in the direction of the orbit's tangent, and the node continually "pulls" it inward.

-
Hopefully this is either still useful to @Mob or at least useful for anyone wanting to do something similar who passes by this question – Attackfarm Apr 22 '13 at 6:12