Skip to content

Clamp Actions

Clamp actions keep a Transform inside defined bounds for position or rotation.

Most clamp actions run continuously in LateUpdate by default, which helps ensure clamping is applied after other movement actions in the same frame.

Clamp Position

Use these actions to keep a Transform inside min/max position limits:

Action Description
TransformClampPosition Clamps X, Y, and Z position using min/max values.
TransformClampPosition2D Clamps X and Y position (2D-style bounds).
TransformClampPositionX Clamps only X position.
TransformClampPositionY Clamps only Y position.
TransformClampPositionZ Clamps only Z position.

Shared parameters

Parameter Description
Transform The Transform to clamp.
Space World or local space.
Min / Max values Axis bounds used by the selected clamp action.

Clamp Rotation

TransformClampRotation clamps rotation around one local axis.

Parameter Description
Transform The Transform to clamp.
Rotation Axis Local axis to constrain (X, Y, or Z).
Min Angle Minimum allowed angle.
Max Angle Maximum allowed angle.

Notes

  • Rotation range is relative to the parent transform (or world space if there is no parent).
  • Only the selected axis is clamped. Other rotation axes are preserved.

Wrap Across Screen

TransformWrapAcrossScreen wraps a Transform across screen edges (for example, leaving left side re-enters on right side).

Parameter Description
Transform The Transform to wrap.
Camera Camera viewport used to determine screen bounds.
Wrap Left Wrap when position exits left edge.
Wrap Right Wrap when position exits right edge.
Wrap Top Wrap when position exits top edge.
Wrap Bottom Wrap when position exits bottom edge.

Example

Use this for classic arcade movement:

  1. Add TransformWrapAcrossScreen to the moving object.
  2. Set Camera to your gameplay camera.
  3. Enable all wrap directions.
  4. Move the object normally with your movement actions.

When the object exits one side of the screen, it appears on the opposite side.

Wrap Transforms In Sphere

WrapTransformsInSphere wraps a list of transforms inside a sphere around a center transform.

When a transform leaves the sphere radius, it is teleported to the opposite side of the sphere.

Parameter Description
Transforms List of transforms to wrap.
Center Center of the wrapping sphere (commonly the player, camera, or ship).
Radius Radius of the wrapping sphere in world units.

Example

Use this for 3D asteroids-style world wrapping:

  1. Create a TransformList containing your moving objects.
  2. Set Center to the player or camera transform.
  3. Set Radius to your active play area radius.
  4. Run every frame so objects that exit the sphere wrap to the opposite side.