# MAttack Trigger

## &#x20;Overview&#x20;

This component is the default damager used with colliders to do damage to the characters.

It requires a collider set as a trigger. By default, it will create a box collider when this component is added to a gameobject.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FxugJ5yPGSUPlqYsFa0I5%2Fimage.png?alt=media&#x26;token=52db1662-24ca-4aec-b7e4-ad893a921f5a" alt=""><figcaption></figcaption></figure>

![Different Attack Triggers represented by a Red Gizmo](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MWZlFoQdN6cv3j1vY6m%2F-MW_NspVOex9ZG3IR3jq%2FLM8KGL7ebu.gif?alt=media\&token=1b9099cd-2e4d-4267-86b9-e4724510d363)

This component works heavily with the Attack Trigger Behaviour. Which Activate the Attack trigger via Animator Behaviours:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FPYj0q2cBKWBXW6Rfn25e%2Fimage.png?alt=media&#x26;token=5e01a6da-a223-4c54-9c8f-8349ec6af138" alt=""><figcaption><p>Add the Attack Trigger Behaviour to your Animations with the Attack Trigger ID and Profile to Activate the Attack Trigger component</p></figcaption></figure>

## General

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FwvZSAqQZLaTJ9QeAqAs1%2Fimage.png?alt=media&#x26;token=14318b8f-f361-4e9d-9cdb-b498d21baab1" alt=""><figcaption></figcaption></figure>

### Trigger

Reference for the Collider needed by this component. This is a required field\*

### Active

Enable/Disable the Damager.

### Index

Index of the Damager. Often used by the Animator to know which Attack Trigger to enable/disable via an Animation.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FW2qlbMCGIb0qi058hi9d%2Fimage.png?alt=media&#x26;token=be2cd61b-c57b-45e9-a54d-e2199227c26d" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Usually, the Animals have more than one Attack Trigger: Horns, Mouth, Claws, Feet, Swords... Each Attack can use this index to activate the proper Damager while making the animation.
{% endhint %}

### Hit Layer

&#x20;Layers to interact with objects. By Default is set that affects only the Animal Layer.

### Trigger Interaction

Set the Interaction that the Damager will have with Triggers.

### Don't hit Owner

When the Damager is using **Raycast** or **OnTriggerEnter**, sometimes it can register colliders inside the same hierarchy the Damager is. When this option is enabled, these colliders will be ignored.

### Owner

By default, the Owner is the Root of the hierarchy. But it can be set Manually to another gameobject. If this value is set to null, it will be set again to the Root of the hierarchy.

## Damager Profiles

Profiles can change the way an Attack Trigger interacts with any Object. Use this to override values of an Attack Trigger depending the Animation is playing. It can be used to create cool finishing Moves of a Combo attack. The final blow can push the Animal Hitted and it can cause twice the damage:

{% embed url="<https://streamable.com/jf59on>" %}

The values inside the Profiles are the same parameters you can override in the Attack Trigger component.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F85n1JwLtDr7za6cGO6YM%2Fimage.png?alt=media&#x26;token=f42bb810-7952-4f52-9772-ff8c7082b2d3" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Use the **Index** of the Profile to activate it. When the Animation Ends the Profile will be restored and the Default values will be applied on the next Attack Trigger Activation&#x20;
{% endhint %}

## Damage

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FnZ1cKnUOfPwu5fsRhKm1%2Fimage.png?alt=media&#x26;token=65d1f1e5-7633-42b2-870c-35b65693367c" alt=""><figcaption></figcaption></figure>

When a Damager registers a collider, it will find any [**MDamageable** ](https://malbersanimations.gitbook.io/animal-controller/secondary-components/mdamageable)Component on its hierarchy and it will apply  all the modifications necessary to that gameobject&#x20;

### Stat

Which StatID do you want to modify and what do you want to do to it? There are various values in the drop-down.

### Min/Max

The minimum and maximum values to modify the stat. If set as the same then it will obviously be a static value.

### Pure Damage

If this parameter is set to true the Damager Receiver ([**MDamageable**](https://malbersanimations.gitbook.io/animal-controller/secondary-components/mdamageable)) will ignore its default multiplier. Resulting in pure damage.

### Element

Type of Element that this Weapon/Attack Trigger can inflict e.g. Fire, Ice, etc.

### Chance

The critical damage will apply a chance to increase or decrease the final value of the Stat modifier. Probability of making critical damage.

### Multiplier

The Stat Modifier value will be multiplied by this value if the critical chance is true.

## Extras

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FcQI8Gp1Xk9Im6F57utS6%2Fimage.png?alt=media&#x26;token=fcc91932-c7f0-4c72-bc62-0262f0283e4a" alt=""><figcaption></figcaption></figure>

### Min/Max Force

When a Damager registers a collider, it will apply a force to the attached rigidbody. You can set the Min and Max Force here.

### Force Mode

Type of force to apply on the ApplyForce() method.

### React

The Damager receiver will apply its default Reaction .

### Custom Reaction

You can set your own custom reaction here. This will override the Damager Receiver default reaction.

### Interact

If the Damage Receiver has any [**Interactable** ](https://malbersanimations.gitbook.io/animal-controller/global-components/interactable)component attached it will send an interaction using the InteractorID value.

### InteractorID

Index to send to the Interactable.

### Hit Effect

This Gameobject will be enabled on impact. If it's a Prefab, it will be instantiated.

### Animator Stop Time

Time the Animator will be stopped. If it's zero, stopping the animator is ignored.

### Animator Speed

Value of the Animator Speed when it's stopped

### Animator

If there's an Animator Controller, it will be stopped

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQMNJ0KNaa3VckKLTqoZW%2Fimage.png?alt=media&#x26;token=a422643b-c5be-4ac9-b842-5b2084b6ae09" alt=""><figcaption></figcaption></figure>

### **On Hit (Transform)**

Invoked when the AttackTrigger hit something. Returns the Damager Receiver Transform as Parameter

### On Hit Position (Vector3)

Invoked when the AttackTrigger hit something. Returns the position of the hit on the Damager receiver

### On Hit Interactable (int)

Invoked when the Damage Receiver is an Interactable.  Returns the Interactable ID as Parameter

### On Profile Changed (Int)

Invoked when the damage profile changes

### On Attack Begin

Invoked when the Attack Trigger is enabled

### On Attack End

Invoked when the Attack Trigger is enabled
