> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinemation.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Align Component: Melee Combat and Object Interactions

> Enable melee combat and interactions. Place the Align Component on a target object to warp your character to the correct position, angle, and distance.

The Align Component handles melee combat and environmental interactions by snapping your character into the correct position and orientation relative to a target object — an enemy, a car, a door, or any interactive GameObject. Instead of attaching it to your character, you add the Align Component to the object your character will interact with. When the player triggers an interaction, the component validates the angle and distance, then the Motion Warping system drives the character to the precise aligned position.

## 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

<ParamField path="Interaction Angle" type="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.
</ParamField>

<ParamField path="Offset Angle" type="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.
</ParamField>

<ParamField path="Distance" type="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.
</ParamField>

<ParamField path="Target Anim Name" type="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.
</ParamField>

## 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 call `Interact` 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`:

```csharp theme={null}
private void OnTriggerEnter(Collider other)
{
    _interactionTarget = other.gameObject;
}

private void OnTriggerExit(Collider other)
{
    _interactionTarget = null;
}

private void TryInteracting()
{
    _warping.Interact(_interactionTarget);
}
```

When `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.

<Note>
  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.
</Note>

<Tip>
  You can also drive `TryInteracting` from an Animation State Machine transition, an Ability System task, or any other game-logic hook — the trigger/exit pattern above is simply the most straightforward approach.
</Tip>

## 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**.

<Note>
  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.
</Note>
