/
Featured Blog

Equation for Space Gravity like Angry Birds Space

The Maths behind the gravity effect of planets in angry birds space is far different from the actual equation of gravity of a real planet.

The Eluding Gravity Equation

When i was programming my first game "Tank in Space" ( which is about manuvering a tank in space like in "A-Team"), i wanted my tank to orbit the Planet. I searched many sites to see how it was implemented in Angry Birds Space, but none could provide a clear picture. After several experiments i succeeded in finding the equation which makes any object revolve around a planet irrespective of speed of arrival inside gravity field.

You can check out my implementation in my game

The Implementation

The normal equation of Gravity is

$F = G frac{m_1 m_2}{r^2}$

If you implement this equation as your planet's gravity equation your object will mostly fly away from field.

Instead of using this equation you can simply accelerate the object towards center of planet by a constant value.

In Unity it is implemented as rigidbody.addforce(ObjToCentervector,Forcemode.acceleration)

This implementation gave rise to another problem. Acceleration increases velocity exponentially which will make the game very difficult to control.

So instead of using Forcemode.acceleration use Forcemode.VelocityChange which makes your game more controllable. Besides you can change the Drag of the rigidbody to have even more control. I used a value of 0.1 for drag which made the tank go upto the edge of field before orbitting. Increase the drag value if youu want the object to orbit earlier. This will however make the object lose velocity soon and spiral into the planet early.

Latest Jobs

IO Interactive

Hybrid (Malmö, Sweden)
3.02.23
Gameplay Director (Project Fantasy)

Arizona State University

Los Angeles, CA, USA
2.27.23
Assistant Professor of XR Technologies

IO Interactive

Hybrid (Copenhagen, Denmark)
3.02.23
Animation Tech Programmer

Purdue University

West Lafayette, IN, USA
3.02.23
Assistant Professor in Game Design and Development
More Jobs

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio