gitwtfhub

wtf is spherical-gravity?

seblague/spherical-gravity — explained in plain English

Analysis updated 2026-08-07 · repo last pushed 2022-06-20

170C#Audience · developerComplexity · 2/5DormantSetup · easy

TL;DR

A Unity code package that makes characters walk around spherical planets instead of flat floors, pulling them toward the planet's center like in Super Mario Galaxy. Drop it into your game to handle curved-surface gravity.

Mindmap

mindmap
  root((repo))
    What it does
      Spherical planet gravity
      Character rotation on spheres
      Walk around small worlds
    How it works
      GravityAttractor script
      Planet tagging system
      Ground layer setup
    Use cases
      Space exploration games
      Asteroid walking scenes
      Round planet platformers
    Tech stack
      Unity
      CSharp
    Audience
      Unity game developers
      Tutorial followers
      Game prototype builders

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Build a platformer where characters walk on tiny round planets without falling off.

REASON 2

Create a space exploration game where astronauts walk on asteroid surfaces.

REASON 3

Prototype a Mario Galaxy-style level with characters strolling around a small globe.

REASON 4

Add spherical gravity to any Unity game with curved terrain instead of flat floors.

What's in the stack?

UnityC#

How it stacks up

seblague/spherical-gravitynextweb4/alias-cockpitlupul64348/nte-cheat
Stars170162158
LanguageC#C#C#
Last pushed2022-06-20
MaintenanceDormant
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedevelopergeneralgeneral

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Requires Unity 5 or later, you need to tag planets as "Planet" and set up a ground layer for surface detection.

No license information is provided in the README, so usage rights are unclear and you should contact the author before using this in a project.

Wtf does this do

Spherical Gravity is a Unity code package that lets game developers add realistic gravity to spherical planets. Instead of characters being pulled "down" toward a flat floor, they are pulled toward the center of a round planet, so they can walk all the way around it. This is the effect you see in games like Super Mario Galaxy, where a character can stroll over the surface of a small world and never fall off, because the gravity always points toward the planet's core. The code works by attaching a script called "GravityAttractor" to any planet object in your Unity scene. That script does the math to figure out which direction is "down" for any character standing on the sphere, based on where they are relative to the planet's center. A separate character controller reads that information and continually rotates the player so their feet stay planted on the ground, no matter which part of the globe they are standing on. You also tag the planet as "Planet" and set up a ground layer so the system knows what counts as solid surface for grounding checks. This is aimed at Unity game makers who want to build levels around planets, moons, or small floating worlds rather than traditional flat terrain. For example, if you are prototyping a space exploration game where astronauts walk on asteroids, or a platformer set on tiny round planets, this handles the tricky physics so your characters behave convincingly on curved surfaces. The project comes from a YouTube tutorial, and the code is fairly minimal and instructional rather than a full-featured framework. It has been updated for Unity 5, so developers using that version or later can drop it into a project and follow along with the video. The README doesn't go into detail beyond the basic setup steps, so you'll likely want to watch the tutorial for the full picture.

Yoink these prompts

Prompt 1
Help me set up the Spherical Gravity Unity package. I have a sphere planet and a character controller, how do I attach the GravityAttractor script and configure the Planet tag and ground layer so my character walks around the sphere?
Prompt 2
I'm using the seblague spherical-gravity Unity code and my character keeps falling off the planet or not rotating correctly. What are the common setup mistakes with the GravityAttractor and ground layer configuration?
Prompt 3
Walk me through adapting the spherical-gravity Unity package for multiple planets in one scene. How would I handle a character traveling between two different spherical worlds each with their own GravityAttractor?
Prompt 4
I want to follow along with the YouTube tutorial that goes with this spherical gravity Unity code. Help me recreate the scene setup step by step so my character can walk all the way around a small planet.

Frequently asked questions

wtf is spherical-gravity?

A Unity code package that makes characters walk around spherical planets instead of flat floors, pulling them toward the planet's center like in Super Mario Galaxy. Drop it into your game to handle curved-surface gravity.

What language is spherical-gravity written in?

Mainly C#. The stack also includes Unity, C#.

Is spherical-gravity actively maintained?

Dormant — no commits in 2+ years (last push 2022-06-20).

What license does spherical-gravity use?

No license information is provided in the README, so usage rights are unclear and you should contact the author before using this in a project.

How hard is spherical-gravity to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is spherical-gravity for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.