This page explains how to use the Corgi Engine's Gravity features.

Introduction

Introduced in version 4.2 of the Corgi Engine, the gravity features will allow you to modify your character’s gravity direction. There are 3 ways you can do that : per character, using Gravity Zones, or Gravity Points. This page covers all that.

Character Gravity Ability

Introduced in v4.2, the CharacterGravity ability is mandatory for your character to have a different gravity direction than the default one.

Jekyll
The CharacterGravity inspector.

From its inspector you’ll be able to decide whether or not the Character is influenced by Gravity Zones and/or points, whether input should be reversed when upside down (that way pressing right, inversing gravity, and keeping pressing right will make your character keep going right on screen), and set the Initial Gravity Angle. That angle will define the default gravity angle for the character. You can select any angle on a 360° scale. 0 is the default, vertical/down gravity angle.

Additionnally, you can define a rotation speed for your character, that will be applied to the character’s transform when going from one gravity to another. Be careful with this setting, as it may cause your character’s “feet” or “head” to exit/enter the zone you’re currently entering, causing glitches. To prevent that, you can define an Inactive Buffer Duration (in seconds), which will prevent the Character from registering any collision with the same (or others) gravity zones when entering/exiting one. Alternatively, you can just set the Rotation Speed to 0, which will make it instant and prevent that kind of glitches.

Gravity Zones

Gravity Zones are a component you can add to any Collider2D (Box, Circle…), to have it modify the gravity of the Characters that enter it. From its inspector you’ll be able to setup a gravity direction, but also a few collider parameters, such as gravity strength.

Gravity Points

Jekyll
Gravity Points examples in the FeaturesGravity demo scene.

Gravity points are a component you can add on any object (even empty game objects), and from their inspector you just have to decide on their area of effect distance. What this will do is that, at all times, the Character will change its gravity direction to point towards the closest Gravity Point whose area of effect it’s in.

Current limits

Right now, moving platforms and falling platforms are not supported when gravity is not set to its default, vertical value. Apart from that, all features of the Corgi Engine are supported in any gravity.