Skip to content

Unity's default gravity assumes that your world is flat. If your planet is round, you will need to write your own gravity. This script accomplishes not only gravity for a spheroidal planet, but also includes a secondary gravity source for a low-orbit moon, causing interesting tidal effects.

ChrisMenning/false-gravity-with-tidal-effect

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

false-gravity-with-tidal-effect

Unity's default gravity assumes that your world is flat. If your planet is round, you will need to write your own gravity. This script accomplishes not only gravity for a spheroidal planet, but also includes a secondary gravity source for a low-orbit moon, causing interesting tidal effects.

In a Unity scene, include an object called "planet", an object called "moon", and at least one object which you want to be affected by the gravitational pull of both the planet and the moon.

Attach the falsegravity.cs C# script to your object and it will fall to the planet, from any direction, and also be slightly pulled on by the gravity of the moon.

A working demo of this can be seen (on Safari, Firefox, and IE only) at the following URL: https://s3-us-west-1.amazonaws.com/collapsiblemedia.com/false+gravity+with+tidal+effect+demo/false+gravity+with+tidal+effect+demo.html

NOTE: The demo example also includes some scripts controlling the rotation of the planet and the orbit of the moon. Those scripts are not included in this repository because they are simple, one-line "transform.Rotate" commands.

About

Unity's default gravity assumes that your world is flat. If your planet is round, you will need to write your own gravity. This script accomplishes not only gravity for a spheroidal planet, but also includes a secondary gravity source for a low-orbit moon, causing interesting tidal effects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages