Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FixedUpdate(){
- // Do the Force calculation (refer universal gravitation for more info)
- // Use numbers to adjust force, distance will be changing over time!
- forceSun = G x (massPlanet x massSun)/d^2;
- // Find the Normal direction
- Vector3 normalDirectionSun = (planet.position - sun.position).normalized;
- // calculate the force on the object from the planet
- Vector3 normalForceSun = normalDirection * forceSun;
- // Calculate for the other systems on your solar system similarly
- // Apply all these forces on current planet's rigidbody
- // Apply the force on the rigid body of the surrounding object/s
- rigidbody.AddForce(normalForceSun);
- // .... add forces of other objects.
- }
Add Comment
Please, Sign In to add comment