Skip to content

Constrainer

Continuously enforces position and rotation constraints on a target transform while active.

Namespace: Octoputs.Constraints Inherits: ControllableComponentMonoBehaviour Implements: ILastLateUpdatable, ILastFixedUpdatable

Overview

Constrainer keeps a target Transform inside spatial limits — bounds, spheres, planes, lines, angle ranges. Each frame the target's position runs through every position constraint in order, then its rotation through every rotation constraint.

When the target has a Rigidbody, Constrainer runs in the last FixedUpdate channel so it executes after every other system has applied forces but before the physics solver integrates — giving attached joints a clean constrained starting state. On dynamic bodies it also projects linearVelocity and angularVelocity onto the constraint tangent, so collisions, joints, and forces can push the body along the constraint surface but never through it.

Without a Rigidbody, Constrainer runs in the last LateUpdate channel so it has the final say after every other transform write.

Inherits its lifecycle from ControllableComponent: the constraining window can be tied to OnEnable/OnDisable, an attachment cycle, an external event, or manual Begin/End.

Properties

Property Type Description
target Transform Transform to constrain. Falls back to this GameObject when empty.
space Space Whether constraints operate on world or local position/rotation.
projectVelocityOnCorrection bool On dynamic Rigidbody targets, project velocity onto the constraint tangent on correction (preserve motion along the surface). Disable for legacy "zero velocity on correction" behaviour.
positionConstraints List<IPositionConstraint> Position constraints applied in order. Empty = position not constrained.
rotationConstraints List<IRotationConstraint> Rotation constraints applied in order. Empty = rotation not constrained.

See Also