Restrict Position
Restrict Position keeps the character root inside a world-aligned X range, Z range, or rectangle. Use it for an arena or a 2.5D lane without building boundary walls. Vertical movement remains available.
Configure valid bounds
- In Ultimate Character Locomotion > Abilities, select + and add Restrict Position. Keep it disabled while entering the bounds.
- Choose the restricted axes and enter ranges containing the character’s current world position. Each minimum must be at or below its maximum. A new ability has all four bounds at
0, so configure them before enabling it. - For a permanent boundary, keep Start Type > Automatic, Stop Type > Manual, and enable the ability. For a temporary scripted area, use Manual activation instead.
- Place it below abilities whose final movement it should clamp. It is concurrent, and active
ApplyPositioncallbacks run in list order.
| Inspector field | Default | Purpose |
|---|---|---|
| Restriction | Restrict XZ | Restrict X leaves Z free; Restrict Z leaves X free; Restrict XZ constrains both. |
| Min X Position / Max X Position | 0 / 0 |
World X bounds when X is restricted. |
| Min Z Position / Max Z Position | 0 / 0 |
World Z bounds when Z is restricted. |
| Start Type / Stop Type | Automatic / Manual | Permanent enabled restriction; no input binding is needed. |

Bounds apply to the root rather than the capsule’s outer surface. Inset them by the required body radius when the whole character must remain inside a visible edge. Use world coordinates even when the level, parent, or platform has its own transform.
Arena, lane, or temporary mode
For an arena, select Restrict XZ, X -10 to 10, and Z -8 to 8: a 20-by-16-unit root range. For a world-aligned side-scrolling plane, select Restrict Z and a narrow range such as -0.1 to 0.1, leaving X free; pair it with Pseudo3D movement.
A temporary zone can use manual start/stop calls or a State preset that changes Enabled. Keep an automatic ability disabled when the mode is off; stopping it while still enabled permits another automatic start on the next update.
Use physical boundaries or a project-specific reference-frame ability for moving or rotated regions. The built-in ranges remain aligned to world X/Z.
Coordinate movement and animation
During position application, the ability clamps Target Position and replaces Desired Movement with the offset to that clamped target. Y and unrestricted axes stay unchanged. Configure later movement writers so they preserve the restriction.
Add Stop Movement Animation below the restriction when held input at the invisible edge should return locomotion to idle. It predicts a crossing of the active restriction and clears horizontal movement/input. Restrict Position itself requires no Animator state or ability index.
Give NavMesh and Move Towards destinations inside the allowed bounds, or handle a blocked destination in the movement owner. Reaching the edge does not complete an outside target.
Verify the boundary
- Enter Play Mode inside the configured ranges. Confirm (Active), then approach each edge and a corner. The root should stop at the world coordinates while terrain still changes Y.
- Move on an unrestricted axis and confirm it remains free. Inspect capsule clearance against the visible border.
- Hold input against the limit with Stop Movement Animation configured and confirm locomotion idles. Test root motion and every later position modifier used by the character.
- Enter/leave a temporary mode and confirm both the active state and bounds return correctly. Test any moving-platform or teleport flow against the same world-coordinate contract.
For an unexpected clamp, check world-space values, valid min/max pairs, and active State presets. For movement past an edge, inspect later Desired Movement writers. For an AI pressing continuously against the edge, move its destination inside the range.
Control bounds from code
Use the public Restiction property and MinXPosition, MaxXPosition, MinZPosition, and MaxZPosition. RestrictedPosition(ref Vector3 targetPosition) clamps a supplied world position and returns whether a restricted component changed.
This example requires Start Type > Manual:
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;
using UnityEngine;
public class ArenaRestriction : MonoBehaviour
{
[SerializeField] private UltimateCharacterLocomotion m_CharacterLocomotion;
public void EnableArena(float minX, float maxX, float minZ, float maxZ)
{
var restriction = m_CharacterLocomotion.GetAbility<RestrictPosition>();
restriction.Restiction = RestrictPosition.RestrictionType.RestrictXZ;
restriction.MinXPosition = minX;
restriction.MaxXPosition = maxX;
restriction.MinZPosition = minZ;
restriction.MaxZPosition = maxZ;
m_CharacterLocomotion.TryStartAbility(restriction);
}
public void DisableArena()
{
var restriction = m_CharacterLocomotion.GetAbility<RestrictPosition>();
m_CharacterLocomotion.TryStopAbility(restriction);
}
}
Activation uses the shared ability lifecycle. See Abilities, Restrict Rotation, and NavMeshAgent Movement for related ordering and control.