How would I go on about creating a planet in Godot ? Basically a shpere in which when a rigidbody comes a certain distance close, it starts to get attracted towards the centre. Can I manipulate the gravity vector ? I saw that an Area Node can override gravity. Help is much appreciated.
Godot 4 Planet
- Edited
The exact implementation is going to depend. Are you making planets to scale vs spaceships, or are they a reduced size (Something like universe simulator)? How many bodies are you considering? Are planet orbits going to change, be on rails, or planets be static? Are you looking to do moons? Did you want L-points? Landing on planets? How close will the camera get?
- Edited
Game physics engines assume a certain scale. How you implement gravity is going to depend on the details of your project. If you are just dealing with one planet, check out https://docs.godotengine.org/en/4.0/classes/class_physicsserver3d.html and AREA_PARAM_GRAVITY_IS_POINT and AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE. If you planet even close to the real life earth size you might consider compiling the engine with double point, you would have to test it.
If you are modeling a solar system, you would set global gravity to 0. Use the _physics_process() for each object and calculate the forces exerted on the object (n-body problem if you want L points, or sphere of influence calculations) using F= G m1 m2 / d2
- Edited
GDQuest has a video that may lead you in the right direction