# New Interaction System

## Introduction to JU Interaction System

With the new interaction system, it is possible to dynamically interact with the scenario and create interactive props like buttons and light switches.

To see how to use the system as in the GIF below, see the Interaction System demo scene and read the next topics.

<div data-full-width="true"><figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FqcBg0e2a20JMK9iTNpVN%2FUnity_Ob44JNcA83.gif?alt=media&#x26;token=4ac99cde-3d4e-4057-a8f5-2f2b2f35e44b" alt=""><figcaption></figcaption></figure></div>

## JU Interaction System

This script controls the character's interaction system and checks for interactable triggers.

{% hint style="info" %}
This script must be attached to the player.
{% endhint %}

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FBX0KjJ62KnRVZkgq8VdZ%2Fimage.png?alt=media&#x26;token=3798fddc-9a21-4283-8a55-d7c94479d43f" alt=""><figcaption></figcaption></figure>

| Variable            | Description                                                                                                                                         |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| Use Default Inputs  | Enables the default input configuration.                                                                                                            |
| Inputs              | Reference to the [player input asset](https://julhiecio.gitbook.io/ju-tps-documentation/input-controls#input-controls-files) used for interactions. |
| Layer               | Layer mask to detect interactable objects.                                                                                                          |
| Avoid Obstacles     | Defines whether obstacles block interaction checks.                                                                                                 |
| Check Range         | Distance range to search for interactable objects.                                                                                                  |
| Auto Check          | Enables automatic checking for interactables.                                                                                                       |
| Auto Check Interval | Time interval between automatic interaction checks.                                                                                                 |
| Interaction Enabled | Defines whether the interaction system is active.                                                                                                   |
| On Interact         | Unity Event triggered when interacting with an interactable object.                                                                                 |

## JU General Interactable

This script is used to create various interactive objects, allowing you to easily call functions via Unity Events.

{% hint style="info" %}
&#x20;The gameobject with this script must have an "Interactable" tag and a Collider with "IsTrigger" enabled.
{% endhint %}

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FT11IxfTyMZfNaFsLyvNp%2Fimage.png?alt=media&#x26;token=d4b2a5de-07c3-49e8-8593-f40f4a37c316" alt=""><figcaption></figcaption></figure>

| Variable                     | Description                                          |
| ---------------------------- | ---------------------------------------------------- |
| Interaction Enabled          | Defines whether the interaction is enabled or not.   |
| Interact Message             | Message displayed when interacting with the object.  |
| On Interact                  | Unity Event triggered on interaction.                |
| Is Toggle                    | Defines if the object acts as a toggle switch.       |
| Toggle On\_Interact Message  | Message displayed when the toggle is turned on.      |
| Toggle Off\_Interact Message | Message displayed when the toggle is turned off.     |
| Toggle On Event              | Unity Event executed when the toggle is activated.   |
| Toggle Off Event             | Unity Event executed when the toggle is deactivated. |
| Is Toggle On                 | Define toggle state                                  |

## JU Vehicle Interactable

This script works for the character to be able to enter a vehicle, this script must be attached to a trigger that is a child of a vehicle gameobject and with the "Interactable" tag.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2Fcb99dbpAzBw2XSf5O8zt%2Fimage.png?alt=media&#x26;token=40298e00-1a6c-44d4-8e71-5fa16dfe392d" alt=""><figcaption></figcaption></figure>

## JU Vehicle Interactable

This script is actually a base class for all interactables; if you attach it to a game object alone, nothing will happen.\
This base class has virtual functions that can be overridden to create logic for a unique interactable.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julhiecio.gitbook.io/ju-tps-documentation/game-development/new-interaction-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
