Skip to content

marciosouzajunior/Gravity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gravity 🪐

This is a Unity project that simulates space gravity. It implements the following gravity equation:

Where F is the force due to gravity, between two masses (m1 and m2), which are a distance r apart and G is the gravitational constant.

How it works

The PlanetGravity script must be attached to an object the will exert gravity force. Then set property "Object to Attrach" with the object to apply the force.

Orbit

An object can be put in orbit by setting the property Orbity to true:

image

In this case the following equation will be applyed to calculate the object velocity:

image

The direction of the object velocity always points along a tangent to its orbital path (blue line). And the planet gravity acts as a centripetal force (red line).

image

The magnitude of the velocity does not change due to gravity, but the direction constantly changes because the gravitational force constantly redirects it along a circular path. At any point in the orbit, the directions of the two quantities always point at a right angle, or 90 degress,to each other.

Demo

gif_animation_006

References

About

Unity Space Gravity Simulator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages