# Aligner

## Overview

Align the position and rotation of a Target Object to a gameObject with this component. Usually, this component is used by the Zones to align the Animal that uses it.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FNHviGMVIZOgWklRQb7T8%2Fimage.png?alt=media&#x26;token=92c26027-d74a-42d3-a81e-b3018194a957" alt=""><figcaption></figcaption></figure>

## Limitations

This only works when the animal is grounded.

## How to use it

Let's take the Chest Sample on the Demo scene: ***1 - PlayGround Human (1 - Holsters)*** as an example. In this scene, when you approach the central chest, Steve will be aligned (Re-position and oriented\_ so it plays the animation in the right direction/position:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fa7RPIIn2wPxh6xbHtQUX%2FUnity_LWCBvA94D6.gif?alt=media&#x26;token=4161f545-9344-41c2-9c79-924c5bf3cd52" alt="" width="505"><figcaption></figcaption></figure>

To use it, you need to call the function: **`Aligner.Align(Transform TargetToAlign).`**&#x20;

In the chest example. Whenever an Animal enters the Zone, it will tell the aligner to align the entering character to the correct position.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F9KpMwGafXkb6Sinn1Uk2%2Fimage.png?alt=media&#x26;token=b809b7ea-1602-4d55-83f7-5a0cc2103ebe" alt="" width="531"><figcaption><p>When its used make sure you connect the Aling() method to the Dynamic option</p></figcaption></figure>

## Parameters

### Position

Align the Target to the Position of the Main Point.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FCzK98BPTSl3LqcaqcfHP%2FUnity_nqBkxt2Vzb.gif?alt=media&#x26;token=2a7c58fd-9ba8-4daa-a053-2fff3697662e" alt=""><figcaption><p>The character will move to the Align point Position</p></figcaption></figure>

If the Second Point is set, then it will align the Target to the closest point on the line made from both points.

<div align="center"><figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FO5JlUjXuzXbcukzNeFOI%2FUnity_AodPYD7ech.gif?alt=media&#x26;token=3f3b98c2-958f-4a1d-b8c7-389311dd42ae" alt="" width="285"><figcaption><p>Alinging  closer to the left point</p></figcaption></figure> <figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fsi4zNoYHRJBcc4CNsOvX%2FUnity_WiJAL0WJsZ.gif?alt=media&#x26;token=c3ad7480-43b2-4e7c-8c21-ce2f0312c48c" alt="" width="296"><figcaption><p>Alinging closer to the right point</p></figcaption></figure></div>

### Rotation

Orient the target to the rotation of the Main Point.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FOcP37jA8z6gGHnENklcw%2FUnity_FlVI7KYkHi.gif?alt=media&#x26;token=83a80e2c-2f41-4641-aca2-5ef35275d9f1" alt=""><figcaption><p>The character rotates using the Main Point Rotation</p></figcaption></figure>

### Look At

Orient the Target to look at the Main Point Position.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FnyTvYGfZn9RzN1zD2rid%2FUnity_lUjAGFXUA4.gif?alt=media&#x26;token=4bd2cadd-1f66-405b-a6a5-17043f19cd59" alt="" width="563"><figcaption><p>The character looks at the Aligner (but it does not reposition because the Radius is zero)</p></figcaption></figure>

### Radius (Look At)

If the Radius is greater than zero, then the Target will be positioned also to the closest position on the radius created from the look-at.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fzb5vS8G9OGNE9mD6HnB6%2FUnity_hpuNsHPSl6.gif?alt=media&#x26;token=db7b0847-b15b-489f-8596-1bca42c91334" alt="" width="563"><figcaption></figcaption></figure>

### Double Sided (Position - Rotation)

Allows the Target to align correctly to a Double Side Position and rotate correctly to the rotation of the aligner. This is useful when you want 2 different positions and rotations, when facing an aligner in a 180 direction.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FyjEtWzaRSeytKk9NdMGW%2FUnity_AHic5tvFKL.gif?alt=media&#x26;token=7d613e1d-3aa0-4030-9dc2-3fd1e9b095f9" alt="" width="465"><figcaption></figcaption></figure>

### Main Point

Main Transform to use as Position, Rotation and Look At values to make the Aligment

### Second Point

Extra Transform to use as Position, Rotation.

### Align Time

The time needed to make the alignment

### Align Curve

Interpolation to make the alignment.

### Angle Offset (Rotation - LookAt)

Adds a Rotation offset to the Rotation or Look At alignment.
