# Mobile Setup Guide

Setting your character for mobile devices is very easy. All mobile assets like Buttons and Mobile Joystick can be easily connected to any animal without creating any dependency, using [**MEvents** ](/animal-controller/scriptable-architecture/scriptables/mevents.md)and [**MEvent Listeners**](/animal-controller/scriptable-architecture/scriptables/mevent-listener.md)**.**&#x20;

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

{% hint style="warning" %}
All mobile assets needs the **Unity Event System** and **Graphic Raycast** component attached to the Root Canvas in order to work properly
{% endhint %}

![This is created on a new GameObject automatically when a new Canvas is added ](/files/-MKbyrSco7qEULp7fQxm)

![This is Added Automatically to a new canvas. (You just need to check if its there)](/files/-MKbz1NshT96V9mI1gnd)

## Requirements

{% hint style="warning" %}
The Canvas that will be used as the Holder for all the buttons must have the **Graphic Raycaster** component and the **Event System** GameObject needs to be on the scene.
{% endhint %}

![](/files/-MbTSOjKp7tQHW2LKbMO)

## **Prefabs**

You can find all the Mobile Button prefabs inside this Folder:

***Assets\Malbers Animations\Common\Prefabs\Mobile Input***

![Assets\Malbers Animations\Common\Prefabs\Mobile Input](/files/-MKaLVK0VOSVTK2E6V6-)

{% hint style="warning" %}
When adding any of these prefabs on your scene you will need to add them as a child of a **canvas.**
{% endhint %}

### Mobile Joystick

The mobile Joystick prefab uses the [**MobileJoystick** ](/animal-controller/mobile/mobile-joystick.md)component. It calculates a  Vector2 value that later is used to move the Camera or the Animal

![](/files/-MKc2Js2z8TTxCQtw1qS)

### Mobile Button

All the mobile buttons will Raise Events with any Value (Float, Int, Bool, Etc) and those event will be listened by the Animal. and it will act depending of the Event connection with the Animal.

![](/files/-MKc8nvcMi7-rSjRCuaK)

E.g. The Jump Mobile Button has an Event Trigger component with 2  Base Event Data: Pointer Down and Pointer Up. Which register when the Button is Pressed and Released. They Use the Set Jump Event with its boolean value.

![](/files/-MKaOWAGPJ5VZzUVJ649)

And this Event is listened by the Animal on its MEvent Listener Component

![](/files/-MKaQ85z36SfljArwM7-)

And it's connected to the `StatePin` and `StatePinByInput` Methods. Allowing the Animal to Jump.

{% hint style="info" %}
This setup can be done to Activate any State. You just need to change the ID.
{% endhint %}

## Examples:

### Adding Default Event Listeners to a Character

To add the Default list of listeners to an animal you can use the Context menu -> **Create Event Listeners** on an Animal Component.

![](/files/-MKbxWeUylhmq3aBOE_D)

This will add this Default list of listeners and it will connect them to the Animal Component

![](/files/-MKbxnfulwUKgaWEDOqy)

You can find Button Examples you can use inside as buttons for your Mobile Canvas they are located here:

### Creating a button for a State

To Connect a State with a button you can use any of the prefabs provided for those State Buttons on the [**Prefab Folder**](/animal-controller/mobile.md#prefabs)

For example lets Study the Jump Button prefab

You will see that the button Invokes a [**MEvent** ](/animal-controller/scriptable-architecture/scriptables/mevents.md)**Set Jump** when is Pressed, sending a bool **Value = True;** and Invoke again the [**MEvent** ](/animal-controller/main-components/manimal-controller/events.md)when the button is released, sending a bool **Value = False;**&#x20;

![](/files/-MbTTQAbKmdEAs3-Mupl)

This is connected to the Animal via an MEvent Listener. Which is connected to the Jump Logic on the Animal. It Changes the Input Value of the Jump State:

![](/files/-MbTTmT6Dn1Mx7YUOXRy)

To connect any other State; Recreate this values with a different MEvent asset and a different State ID Value.

### Creating a button for a Mode

To Connect a Mode with a button you can use any of the prefabs provided for those Mode Buttons on the [**Prefab Folder**](/animal-controller/mobile.md#prefabs)

### Creating a button for a Stance

To Connect a Stance with a button you can use any of the prefabs provided for those Stance Buttons on the [**Prefab Folder**](/animal-controller/mobile.md#prefabs)


---

# 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://malbersanimations.gitbook.io/animal-controller/mobile.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.
