- Home /
How could I simulate planetary gravity that has an orbit point?
How do you guys suppose I do this? I want to make it so that I can give an object gravity like a planets that has an orbiting point. If I make the gravity will it automatically have an orbiting point? I want to learn more about how to do this. Thanks for any help. If you want an idea of my hopeful result is something like how Kerbal handles planetary gravity.
Answer by Clet_ · May 05, 2014 at 11:51 PM
Obviously, you'll need to implement your own physics and get rid of all the PhysX built-in gravity.
The trick with planetary-like gravity, is that it's somewhat easy to simulate for perfectly spheric planet, but get relatively hard for non-spheric planets.
For a perfectly spheric planet, all you need to do is to apply the "down force" towards the gravity centre and any jump force in the opposite direction. Such direction can be calculated with
Vector3 gravityDirection = (planet.gravityCenter.position - player.transform.position).normalized;
assuming that planet.gravityCenter is a Transform.
If you want realistic-ish physics, I'd suggest to look into Newton's Law of Universal Gravitation, which takes into account the mass of the 2 objects attracting each other and the distance from each other
Would it be hard to make this effect the acceleration of a gameobject and how force acts against the pull or would it do that on it's own? Also would this allow implementation of an orbital system?
I've been reading about Newton's Laws and such and I'm working on a script for it right now. Thanks for the help!
Your answer
Follow this Question
Related Questions
Faux Gravity Prolem? #2 2 Answers
problems with single body Newtonian physics emulation 0 Answers
How do i stop rigid bodies jumping? 1 Answer
How to make an axis always face an object? 2 Answers
Changing gravity affecting 'random movement' behaviour script - my NPCs go crazy, what should I do? 1 Answer