orbiting with gravity? like a satellite around earth

jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
edited November -1 in Working with GS (Mac)
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?

Comments

Sign In or Register to comment.