Guest User

Untitled

a guest
Jun 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. void FixedUpdate(){
  2. // Do the Force calculation (refer universal gravitation for more info)
  3. // Use numbers to adjust force, distance will be changing over time!
  4. forceSun = G x (massPlanet x massSun)/d^2;
  5.  
  6. // Find the Normal direction
  7. Vector3 normalDirectionSun = (planet.position - sun.position).normalized;
  8.  
  9. // calculate the force on the object from the planet
  10. Vector3 normalForceSun = normalDirection * forceSun;
  11.  
  12. // Calculate for the other systems on your solar system similarly
  13. // Apply all these forces on current planet's rigidbody
  14.  
  15. // Apply the force on the rigid body of the surrounding object/s
  16. rigidbody.AddForce(normalForceSun);
  17.  
  18. // .... add forces of other objects.
  19. }
Add Comment
Please, Sign In to add comment