A Godot-Plugin for simulating gravitational attraction between bodies in 3D-Space. Any class that inherits from Spatial can be added to the simulation.
-
Add NBodySimulation3D-node to your scene.
-
Add all Elements that should attract each other as children of the simulation node.
-
every node that should be affected needs the properties
mass: float
andvelocity
, so make sure to add those to their scripts.
-
-
Modify the parameters of the NBodySimulation3D to fit your case.
-
G: The gravity constant. This determines how much the planets attract each other
-
Time Multiplier: Slows or speeds up the simulation time.
-
Theta: Threshold for the octant-size / distance ratio. The higher the value the simulation can be calculated but the less accurate it gets. See The Barnes-Hut Algorithm for reference.
-
-
Start the scene and the simulation will automatically compute die forces and move the bodies.
Note
|
If you use RigidBody-nodes inside the N-body simulation,
make sure to set physics/3d/default_gravity to 0 in your project settings.
Otherwise the bodies will still be affected by the linear gravity of the world.
|