# Mode Aligner2

***

## Overview

Mode Aligner is used to align the character to a target while executing a mode. Usually, to make the Attack animation to Look At the target is going to attack.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FI6dqI2jnfNSz4dD1rinC%2FUnity_FdRuIuZmG0.gif?alt=media&#x26;token=b409e2b9-4c60-4f57-a919-39dfcbaa92a7" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
If you are using the old version Mode Align, please upgrade to the new **Mode Aligner 2**
{% endhint %}

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FYuKKHd97nFtrxe6iXbfw%2Fimage.png?alt=media&#x26;token=3f8d29ca-0224-487d-9d3f-16b490d9c455" alt=""><figcaption></figcaption></figure>

***

## How it works

This component subscribes to the **MAnimal** component's \[OnMode Start] event, and listens every time a mode is played. Then it searches the "Align Targets" **Runtime Object Set** for possible near targets, using the *Search distance*. If one of the **aligners** on the list uses the **mode** that the **animal** is playing and it fulfills all the conditions, then the character will be aligned towards the target found.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F8tGW2OmR4r64QNo70tf0%2Fimage.png?alt=media&#x26;token=ddaa5e9a-b4d4-4419-b938-afdaf514fe81" alt=""><figcaption></figcaption></figure>

***

## Requirements

* An **Animal Controller** component. It does not have to be in the same gameobject as the Animal script. I recommend setting this component in a Child GameObject.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FL5yq2mJrLez9w5eBLjgs%2Fimage.png?alt=media&#x26;token=dd40b0f9-8d42-495c-bc04-909f0c7a2d2b" alt=""><figcaption></figcaption></figure>

* Requires a **RuntimeGameObject** set that will be used for storing all the possible alignment targets.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F7DULrbIBh9Buc61Ns0s9%2Fimage.png?alt=media&#x26;token=ef426aa4-955e-4282-a9f7-b542cac43ee7" alt=""><figcaption></figcaption></figure>

* The possible targets need to be on the set. This is achieved by adding the **AddRuntimeSet** component to the targets.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FBtO2QySs8KFeIdwDKZYq%2Fimage.png?alt=media&#x26;token=599074ff-7463-4e08-b8ed-9453c5c01a86" alt=""><figcaption></figcaption></figure>

* Possible targets should also have an **AITarget** component. This will be used to extract the **target's radius** to achieve a better alignment.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F5jYQj1qLxiM5izZRKSjg%2Fimage.png?alt=media&#x26;token=56fe5a9e-db55-4b29-89f9-3d0ac47fbf31" alt=""><figcaption></figcaption></figure>

***

## Parameters

### General

#### Animal

Reference for the Owner of the Mode aligner

#### Set

Current aligner targets. ⚠️Possible aligner targets must have the **AddRuntimeObject** component.

#### Self Radius&#x20;

Radius of the owner to reposition when Use Radius is active. This radius prevents the animal from getting inside another target. &#x20;

#### Search Distance

Distance to compare which is the closest possible target to align. If none of the targets are within this radius, then the Alignment will be ignored

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FSqNAu3MLkqzYOcMqCNuU%2FUnity_gY2EqOpXMP.gif?alt=media&#x26;token=45663e0a-a6e6-4247-abc1-a414d1c69358" alt=""><figcaption></figcaption></figure>

***

### Aligner Data

Every aligner data is a set you can do for each mode and/or abilities

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FGeRaEGbizi7OHahd9iZR%2Fimage.png?alt=media&#x26;token=240b299e-9e16-421a-b3ee-4f8f0510b1f5" alt=""><figcaption></figcaption></figure>

#### Active

Enable or disable the Aligner Set. Disabled aligners will be ignored

#### Name

Name or description for the Aligner Set

#### Mode

Mode that the Aligner will listen to

#### Specific Abilities

What abilities to include or exclude? If the list is left empty, then the aligner will be active when the mode plays

#### Include/Exclude

Include or exclude toggle for the ability list

#### Conditions

Extra conditions to check to activate the aligner

#### Align Time

How long will the alignment last

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F9OfUIpDsm6y6FuuHfBHL%2FUnity_9r3UZn7Ydk.gif?alt=media&#x26;token=4a145ba8-a97b-4135-b283-16f4795511f7" alt=""><figcaption></figcaption></figure>

#### Delay

Delay value to wait to activate the alignment. Use it for abilities that have anticipation.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fqd6DSm14japMSkGuCl8I%2FUnity_CjSUdjgCC3.gif?alt=media&#x26;token=d9f229e8-50c7-4138-946e-426a0e248bf5" alt=""><figcaption></figcaption></figure>

#### Angle Offset

Offset rotation to apply to the alignment. Use the Offset for abilities that need the character to be in a certain angle. E.g. a execution from the back requires the character to turn 180 degree.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FMNq3EXEKu1LcrMhf8V28%2FUnity_9zC6EsivCu.gif?alt=media&#x26;token=8cdd7390-dd59-4815-bd33-f4363569cee1" alt=""><figcaption></figcaption></figure>

#### Align Curve

Curve value to apply to the alignment

#### Use Radius

When true, the aligner will move the animal closer to the target. Using the **AI Target Radius** values to position correctly, or the **SelfRadius** if there's no **AI Target** found.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fk3mMGPPL21GwZlpfKsnA%2FUnity_4E95bgBPeo.gif?alt=media&#x26;token=175d7d77-fb0f-48c2-a1c9-050c977e657f" alt=""><figcaption></figcaption></figure>

#### Ignore Close

It will not move the character backwards if it is too close to the target.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FreUUglKBFfUNYL362zjL%2FUnity_ywlpGIWNpp.gif?alt=media&#x26;token=b73ca4c9-4d7a-4af7-898f-38d4c80bb669" alt=""><figcaption></figcaption></figure>
