Align To Gravity Zone reorients the character and, by default, its gravity as the character enters a Gravity Zone trigger. Use it for spherical worlds, transitions between differently oriented surfaces, or another area where world-down should not remain the character’s down direction.

Before you begin

  • The character must have an Ultimate Character Locomotion component and the Align To Gravity Zone ability.
  • The character’s main collider GameObject must use the Character layer so a Gravity Zone can recognize it.
  • Each Gravity Zone needs a trigger Collider. A Spherical Gravity Zone specifically requires a Sphere Collider on the same GameObject.
  • Avoid running another system that writes the character’s up direction at the same time. Align To Gravity Zone stops an active Align To Ground ability when the zone alignment begins.

Add the ability and a spherical zone

  1. Select the character GameObject.
  2. In the Ultimate Character Locomotion component, expand Abilities.
  3. Select the plus button and add Align To Gravity Zone.
  4. Keep Enabled selected and both Start Type and Stop Type set to Manual. Gravity Zone trigger callbacks start and stop the ability, so it does not need an input binding.
  5. Set Align Smoothing, Align Gravity Direction, and Stop Direction for the transition required by the scene.
  6. Create or select the GameObject at the center of the spherical gravity area.
  7. Add a Sphere Collider, enable Is Trigger, and set its radius and Transform scale to cover the intended area.
  8. Add Spherical Gravity Zone to the same GameObject.
  9. Configure Influence and Influence Multiplier, then enter Play Mode and cross the trigger boundary with the character.

The demo places spherical zones around exterior planets so the character’s up direction points away from each planet center.

Character between exterior planets whose overlapping spherical Gravity Zones orient the character toward their surfaces

Choose alignment and exit behavior

Align Smoothing is the smoothing time used while the character changes orientation. Its default is 0.2.

  • Reduce it for a quicker response when crossing a sharp gravity boundary.
  • Increase it for a slower transition when the character has enough space to rotate gradually.
  • Test the value at the character’s fastest expected entry speed; a visually smooth transition can still be too slow for collision and movement needs.

Keep Align Gravity Direction enabled when gravity should pull opposite the newly selected up direction. Disable it only when another system deliberately owns Gravity Direction and this ability should change orientation without changing that force.

Stop Direction controls the orientation applied when the final zone is unregistered:

  • Leave it at (0, 0, 0) to keep the last zone orientation after the ability stops.
  • Use a normalized direction such as (0, 1, 0) to return to world-up when the character leaves all zones.

Configure spherical influence

The spherical zone’s Transform position is its center. For a character inside the Sphere Collider, the zone returns an outward direction from that center, making the character’s gravity point inward when Align Gravity Direction is enabled.

Influence is an Animation Curve evaluated by distance. Its horizontal value is 0 at the sphere radius and 1 at the center; its vertical value controls the strength at that distance. Influence Multiplier scales the result, allowing a larger or more important zone to outweigh another zone in an overlap.

Use the Collider radius to define where the zone registers the character, and use the curve and multiplier to decide how strongly it competes inside an overlap. Avoid opposing directions with equal strength in an airborne overlap because their sum can cancel and leave no new alignment direction.

How overlapping zones run

Entering a Gravity Zone registers it with the ability. The first registered zone starts Align To Gravity Zone, enables up-direction alignment, and begins smoothing toward the zone result.

When the character is airborne, the ability adds the direction vectors from every registered zone and normalizes the result. The vector magnitude returned by each zone therefore acts as its weight.

When the character is grounded, the ability uses only the registered zone with the strongest direction magnitude. This prevents a second overlapping zone from pulling the character away from the surface currently supporting it.

Leaving a trigger unregisters that zone. The ability stays active while at least one zone remains, then stops after the last zone is removed and applies Stop Direction when configured. The ability is concurrent and can remain active with compatible locomotion abilities.

Verify in Play Mode

  1. Keep the Ultimate Character Locomotion Inspector visible and move the character into one Gravity Zone.
  2. Confirm (Active) appears beside Align To Gravity Zone.
  3. Confirm the character’s up direction turns toward the zone result at the rate implied by Align Smoothing.
  4. With Align Gravity Direction enabled, jump and confirm gravity pulls opposite the character’s new up direction.
  5. Enter an overlap while airborne and confirm the character follows the weighted blend between both zones.
  6. Land inside the overlap and confirm the strongest zone controls orientation instead of the blended airborne direction.
  7. Exit one zone and confirm the remaining zone continues to control the character.
  8. Exit the final zone and confirm the ability becomes inactive and the character either keeps its orientation or aligns to Stop Direction, as configured.

Troubleshoot Align To Gravity Zone

  • The ability never becomes active: check that the character has the ability, its main collider is on the Character layer, the zone Collider has Is Trigger enabled, and the physics collision matrix allows the trigger pair.
  • A Spherical Gravity Zone produces an error or no direction: add a Sphere Collider to the same GameObject as Spherical Gravity Zone and give it a nonzero radius.
  • The character orients correctly but falls in the old direction: enable Align Gravity Direction and confirm Use Gravity is enabled on Ultimate Character Locomotion.
  • The character rotates too slowly or snaps too quickly: reduce Align Smoothing for a faster transition or increase it for a slower one, then retest at gameplay speed.
  • The character points toward a planet center instead of standing on its surface: a custom Gravity Zone is likely returning gravity-down rather than the desired up direction. Return the desired character-up vector; the ability negates it when setting Gravity Direction.
  • Orientation flickers while grounded in overlapping zones: adjust Influence Multiplier, the influence curves, or the trigger overlap so one zone remains clearly strongest on that surface.
  • Airborne alignment stalls between zones: check for equal, opposing direction vectors that cancel. Change their influence or overlap geometry.
  • The character remains sideways after leaving every zone: set Stop Direction to the required final up direction, such as (0, 1, 0) for world-up.
  • The ability remains active after leaving: confirm every entered trigger receives an exit and unregisters. A custom zone or a zone disabled while occupied must also call UnregisterGravityZone for the character.
  • Another ability changes orientation at the same time: prevent another up-alignment ability from starting while the zone is active. Align To Gravity Zone stops Align To Ground when it begins, but two active alignment writers should not be deliberately combined.
  • Align To Ground aligns to detected surface normals instead of trigger-defined gravity.
  • Abilities explains manual starts, concurrent abilities, and runtime activation.
  • Layer Manager documents the Character layer used by Gravity Zone triggers.
  • Movement Types explains how movement input is interpreted after the character’s orientation changes.

Developer reference

GravityZone is abstract. A custom zone implements DetermineGravityDirection(Vector3) and returns the desired character-up vector. The vector’s magnitude supplies its relative influence when zones overlap.

using UnityEngine;
using Opsive.UltimateCharacterController.Objects.CharacterAssist;

public class DirectionalGravityZone : GravityZone
{
    [SerializeField] private Vector3 m_LocalUp = Vector3.up;
    [SerializeField] private float m_Influence = 1;

    public override Vector3 DetermineGravityDirection(Vector3 position)
    {
        return transform.TransformDirection(m_LocalUp).normalized * m_Influence;
    }
}

The current runtime surface includes:

  • RegisterGravityZone(GravityZone): adds a zone and starts the ability when it was inactive.
  • UnregisterGravityZone(GravityZone): removes a zone and stops the ability after the final zone leaves.
  • DetermineGravityDirection(Vector3): supplies a custom zone’s weighted alignment vector for the character position.
  • AlignSmoothing, AlignGravityDirection, and StopDirection: expose the inherited Inspector settings.
  • IsConcurrent: returns true.
  • CanStayActivatedOnDeath: returns true.

Align To Gravity Zone does not send a feature-specific event. Gravity Zone trigger callbacks control its registration and lifecycle directly.