Add to the Interaction Target
Attach the AlignComponent to the GameObject your character will interact with — for example, an enemy character, a vehicle, or an environmental prop. Do not add it to the player character itself.Component Properties
float
required
The maximum allowed angular difference (in degrees) between the character’s approach direction and the target object’s forward axis. If the character approaches from outside this cone, the interaction is rejected. This prevents the player from triggering a front-facing attack animation while standing behind the target.
float
required
A yaw rotation offset applied to the Interaction Angle cone. Use this to rotate the valid interaction zone around the target object’s up axis — for example, to allow interactions from a slightly offset frontal arc rather than dead-ahead.
float
required
The maximum allowed distance between the character and the target object. If the character is farther away than this value when
Interact is called, the interaction is rejected.string
required
The name of the animation to play on the target object (the object the AlignComponent is attached to) during the interaction. For example, this could be a hit-reaction animation on an enemy, a door-opening animation, or a vehicle interaction. The character’s animation is controlled separately by the Motion Warping Asset.
How It Works
The most common pattern is to use Unity’s collision trigger system to track which interactable object the character is near, then callInteract when the player presses the appropriate button.
Use OnTriggerEnter and OnTriggerExit on your character to store and clear a reference to the interaction target, then call the Interact method on the MotionWarping component and pass the target’s GameObject:
Interact is called with the target GameObject, the system retrieves the AlignComponent attached to that object and validates the Distance and Interaction Angle checks. If both pass, the warp interaction begins and the character is driven from its current position to the aligned target position.
The
_interactionTarget variable holds a reference to the GameObject that carries the AlignComponent — not the character. Make sure the collision trigger on your character overlaps with the collider on the target object so that OnTriggerEnter fires correctly.Motion Warping Asset Requirements
The character moves from its current position to the aligned position relative to the target object in a single motion, so the Motion Warping Asset assigned to this interaction requires exactly one Warp Phase.The single Warp Phase maps the character’s root motion from its current transform to the position and orientation dictated by the AlignComponent on the target object. Ensure your interaction animation’s root motion faces forward along the character’s local Z axis so the warped alignment is correct.
