I am working on a 2D game, and I am working on adding some space physics, so I need to find a way to create a circular orbit.
I want to make my game object move on a circular way around a planet. I'm starting with the old famous formula:
V = sqrt(G * ((m1 + m2 ) / r))
This formula is the classic real world one, V is the velocity of the game object.
Once I code it, it doesn't move on a circular way, it just being attracted by the planet, like normal gravity. Here's my code (I'm using Unity):
dist = new Vector2(
Planet.renderer.bounds.center.x - renderer.bounds.center.x,
Planet.renderer.bounds.center.y - renderer.bounds.center.y
);
r = dist.magnitude;
rigidbody2D.velocity = dist.normalized * (Mathf.Sqrt (0.5f * ((mBody + mPlanet) / r)));
Dist is a 2D vector and r is a float, The G value is 0.5 (I used this one because 6.673E-11 is very small and it's not what I want)
So the question is is how can I make my GameObject move on a circular orbit like a satellite around earth ?
One thing to note, is that my GameObject is kicked by the player, so it get a speed of 12. (I am using addForce()).