# Point Click

The Point Click component allows for AI animals to move with point-click movement - similar to what you would find in a MOBA or a Top Down RPG - you click, the events fire.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F9sXyaL58v26CWjDWoxLV%2Fimage.png?alt=media&#x26;token=c626ef89-1852-4e97-8923-221a112b0867" alt=""><figcaption></figcaption></figure>

It's not just limited to that though, you can be creative and use the events for other purposes too unrelated to movement!

## Requirements

* It needs an AI Control component and an AI agent already attached to the character.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FtyIAoSrpacrThbaN9eex%2Fimage.png?alt=media&#x26;token=45596ffc-115e-42ed-89f7-98397054084e" alt=""><figcaption></figcaption></figure>

* A Unity Event System needs to be on the scene. This will send all the click events to the script.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FAVZB4EMiZ4zrCg3G51l0%2Fimage.png?alt=media&#x26;token=3612dfc1-c48e-4bf9-b1fa-c142cc64c539" alt=""><figcaption></figcaption></figure>

* Every clickable surface that the animal can walk, needs to have an event Trigger Event with a Pointer Click with the next setting:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FugTLFopPRGP4h1dqRkDR%2Fimage.png?alt=media&#x26;token=7bab7bf6-67cc-4833-a307-51771faa9d22" alt=""><figcaption><p>Point Click is a Sriptable Object that connects the surfaces with the Point Click component</p></figcaption></figure>

* Zones and Interactables components do not need the Event trigger - Pointer Click

## How to Set it Up

In the same AI Control gameobject, add it by searching for Point Click, or by going to Add Component -> Malbers -> AI -> Point Click

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FhBEsY3HprLAlSECe4kA6%2FUnity_X0nCRgvb33.gif?alt=media&#x26;token=ff3bffb7-8f4e-443b-bb05-56914abf8a1e" alt=""><figcaption></figcaption></figure>

This automatically connects all the events and parameters to the AI Control component.

## Parameters

### Point Click Data

Scriptable Object used to record all the Events from the Event trigger - Pointer Click in every clickable surface and this component.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FgTpOizTwmDqruPEDJ2Dq%2Fimage.png?alt=media&#x26;token=5ad0b986-28a2-4165-a479-ae156b3ace23" alt=""><figcaption><p>location of the scriptable object</p></figcaption></figure>

### **Point UI**

Prefab used to display where the point click was made

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fmmv9fCLj94zQqFPNOhxW%2FUnity_ciAdZPXvt6.gif?alt=media&#x26;token=21563583-36f4-4474-b8cc-d0506d3b4e5e" alt=""><figcaption></figcaption></figure>

### Button

What button of the mouse is used. (Left, Right, or Middle Mouse)

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FE32pKBiWWKOTwSqNImJ7%2Fimage.png?alt=media&#x26;token=a2e57ca4-03df-4cc9-89df-a8f33b43600e" alt=""><figcaption></figcaption></figure>

### Radius

Radius to find a possible target nearby when clicking on an empty surface. Possible targets can be a Zone, Interactable, or another animal.&#x20;

### Clear Target

When the animal has a target already assigned, it will clear the current target on the AI control component if the next click is on an empty surface.

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FbZnuTZJvUHuEH7qSlsZm%2Fimage.png?alt=media&#x26;token=35c22921-2e28-4853-8892-399d4b2c555a" alt=""><figcaption></figcaption></figure>

### On Point Click

Invoked when a click on a walkable surface is registered.&#x20;

### On AI Target Click

Invoked when a click on a possible target is registered. (Zone, Interactable, other characters)
