# Interactor

## Overview

This component stores the Index and GameObject of an Interactable and invokes events that can be used to create Reactions according to each interactable value. It also executes the Interaction logic on the Interactable.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fwfly6aWaIglbo0r1n0E4%2Fimage.png?alt=media&#x26;token=7a9e70b1-d595-49a2-b387-8aab4196d783" alt=""><figcaption></figcaption></figure>

## How to use it

Place the Interactor on your character and add an Interaction Area (Collider). This will allow to detect interactables on the scene. When an Interactable is inside the Collider, then the Interaction logic can be activated.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FNRjXCBKp8uNmKm7GwYuy%2FUnity_4225hSiYKa.gif?alt=media&#x26;token=a7cf3d05-918f-4e06-b127-e2542aa93945" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Either the **Interactor** or the **Interactable** gameobject needs to have a **Rigidbody** attached. Otherwise, the Interaction will not occur.
{% endhint %}

To activate the interaction you can add an Input to your Malbers Input Component and connect it directly to the Interactor.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fk0vJxGXO8q9BwFee3JHB%2Fimage.png?alt=media&#x26;token=a9e2e5c1-1742-44f0-b2c1-9b3d9ff8be54" alt=""><figcaption></figcaption></figure>

If the Interactable is set to be Automatic then the interaction wont need Manual activation.

Use the reactions list to have different reactions with different Interactables IDs.

## Parameters

### Layer

What layer will be checked on the interactables

### Trigger Interaction

Does the Interactor interact with triggers or just colliders?

### ID

Index of the Interactor. This parameter is received by the Interactable when Interact() is called to check who was the Interactor that activated the logic

### Interaction Area

Reference for the Collider that will be used for finding interactables \[On Trigger Enter]

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F6dEu7Gd04T8hfbW1P84o%2Fimage.png?alt=media&#x26;token=a82f8b87-795b-461b-841c-f4fda6852131" alt=""><figcaption></figcaption></figure>

### On Interact with (GameObject)

Invoked when the Interact() Method is called. Send as parameter the Interactable GameObject

### On Interact with (Int)

Invoked when the Interact() Method is called. Send as parameter the Interactable Index

### On Focused (GameObject)

Invoked when an Interactable enters the Interaction Area. Send as parameter the Interactable GameObject

### On Unfocused (GameObject)

Invoked when an Interactable enters the Interaction Area. Send as parameter the Interactable GameObject

## Reactions

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FM5BrY5PvODpT8jrBYbC0%2Fimage.png?alt=media&#x26;token=f80cf818-7890-4a3f-bd04-a89bb9dead26" alt=""><figcaption></figcaption></figure>

### Index

Check the Index  of the Focused Iteractable. if is equal, Not Equal, Greater or Less than this value then Apply the Reaction.

### Target

Component that the reaction will be applied to

### Reaction

Reaction to apply to the target if the Index of the Focused interactable matches the Index Value

###
