Help?

Sort:
Avatar of jacobsperber2

Does anyone know how to simulate gravity?

I am trying to make a game where a ship accelerates twords a planet, and i need help

Avatar of PawnUpTwo

Kinda. It depends. Is it 3D or 2D? Also, how exactly do you want those two objects to interact?

Avatar of jacobsperber2

Sorry for not getting back earlier, Ive been really busy.

So Its a 2d game, I want the planet to be stationary, and the ship to turn twords the planet, and accelerate in the planets derection.

Avatar of PawnUpTwo

no problem! I think I can help you with that. I don't know EXACTLY how you want everything to interact but the gist of it is you just have a bunch of variables you are constantly altering. For example: pull, xVelocity, yVelocity, lVelocity, and rVelocity (these variable names can be anything but im just calling them those names to make it clear what each one does). When you press certain buttons that will alter the left, right up, and down velocity variables. "pull" will change depending on how close you are to a planet. Then you want to change the left, right up, and down velocity variables based on how strong (or large of a number) the "pull" variable is. The last step is to change the position of the spaceship (x and y) and the rotation based off of each variable. for example, if xVelocity is -5 change X by -5 (repeat for Y and rotation). let me know if that was confusing lol

Avatar of jacobsperber2

ok I think I get it... thank you!

Avatar of PawnUpTwo

sure happy.png