orbiting with gravity? like a satellite around earth
jonmulcahy
Member, Sous Chef Posts: 10,408
In my new game, the hero moves in a straight line. I want this line to be affected by gravity when it passes a certain actor. So, if he moves in a straight line far away, nothing happens. If he enters 100px away, I want his corse to bend, but still escape the planet's gravity. If he enters 50px away, I want him to spiral into the planet.
in my head I can figure it out, but I'm not sure if this is actually right
situation 1: velocity = 100, gravity = 0: straight line
situation 2: velocity = 100, gravity = 50: line curves, but still escapes orbit
situation 3: velocity = 100, gravity = 200: actor spirals into planet.
I know I could use magnitude to find the distance away, but I'm looking for the best way to adjust the rotation. I know I could probably do something with a timer changing the rotation of the actor, but is there a better way?
in my head I can figure it out, but I'm not sure if this is actually right
situation 1: velocity = 100, gravity = 0: straight line
situation 2: velocity = 100, gravity = 50: line curves, but still escapes orbit
situation 3: velocity = 100, gravity = 200: actor spirals into planet.
I know I could use magnitude to find the distance away, but I'm looking for the best way to adjust the rotation. I know I could probably do something with a timer changing the rotation of the actor, but is there a better way?
Comments
A=Z*v^2/r
So accelerate towards the planet with the formula above.
V = magnitude linVelX, LinVelY
R = magnitude planetX-shipX, planetY-shipY
Z = I made this up, set it to 0 when far away, 1 when close, 5 when crash.
Google centripetal acceleration.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left