# Interactable

Allows interaction between the Player ( Thanks to the InteractManager ) and this object.

Using Interactable.cs, there are different ways you can achieve custom interactions, ***simple*** and ***advanced***.

1. Attach the component to your interactable object:&#x20;

* For ***simple*** interactable objects assign the Interactable Component to an object with a box collider, you can subscribe to the OnInteract event to add your custom behaviour.
* For ***advanced*** interactable objects:
  * Create a new C# script.
  * This new C# script must inherit from Interactable.cs
  * override the base Interact method from Interactable.cs

```csharp
 public class CustomInteractable : Interactable
    {
        
        public override void Interact(Transform player)
        {
            // Custom code on interact
             base.Interact(player);
        }

    }

```

2. Ensure the Interactable Layer is assigned to the same object that contains the Collider & Interactable Component ( or script that inherits from it )

For the Interactable.cs:

* <mark style="color:purple;">interactText</mark>
* <mark style="color:purple;">interactableEvents</mark>
* <mark style="color:purple;">instantInteraction:</mark> If true, Progress Required To Interact from [InteractManager](https://cowsinss-organization.gitbook.io/fps-engine-documentation/content/03.-content/03.5-pick-up-system/interactmanager) will be overrided and set to instant interaction **only for this interactable**.

### Functions | Interactable.cs&#x20;

> <mark style="color:orange;">player ( Transform ) | Protected ( only accessible from scripts that inherit from Interactable.cs )</mark>
>
> Player that interacts with the Interactable.

{% hint style="info" %}
Since 1.3, InteractManager passes the player directly to the Interactables.&#x20;
{% endhint %}

> <mark style="color:green;">Interact(Transform player) -> Virtual Method</mark>
>
> Interact with the Interactable object.&#x20;
>
> * player: Transform that interacts with this interactable

> <mark style="color:green;">Highlight() -> Virtual Method</mark>
>
> Triggers when an Interactable is highlighted.
>
> * player: Transform that interacts with this interactable

> <mark style="color:green;">Unhighlight() -> Virtual Method</mark>
>
> Triggers when an interactable is no longer highlighted.
>
> * player: Transform that interacts with this interactable

{% hint style="warning" %}
IsForbiddenInteraction is only available in >1.3.6
{% endhint %}

> <mark style="color:green;">IsForbiddenInteraction(WeaponController weaponController) -> Virtual Method, Returns a Boolean</mark>
>
> Returns whether the interaction is valid or not. Returns false by default, meaning that the interaction can be performed.
>
> * weaponController: You can use the WeaponController to access specific components or properties to determine if an interaction is valid, in case you need it.
