📱
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 and MEvent Listeners.
All mobile assets needs the Unity Event System and Graphic Raycast component attached to the Root Canvas in order to work properly

This is created on a new GameObject automatically when a new Canvas is added

This is Added Automatically to a new canvas. (You just need to check if its there)
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.

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
When adding any of these prefabs on your scene you will need to add them as a child of a canvas.
The mobile Joystick prefab uses the MobileJoystick component. It calculates a Vector2 value that later is used to move the Camera or the Animal

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.

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.

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

And it's connected to the
StatePin
and StatePinByInput
Methods. Allowing the Animal to Jump.This setup can be done to Activate any State. You just need to change the ID.
To add the Default list of listeners to an animal you can use the Context menu -> Create Event Listeners on an Animal Component.

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

You can find Button Examples you can use inside as buttons for your Mobile Canvas they are located here:
To Connect a State with a button you can use any of the prefabs provided for those State Buttons on the Prefab Folder
For example lets Study the Jump Button prefab

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:

To connect any other State; Recreate this values with a different MEvent asset and a different State ID Value.
To Connect a Mode with a button you can use any of the prefabs provided for those Mode Buttons on the Prefab Folder
To Connect a Stance with a button you can use any of the prefabs provided for those Stance Buttons on the Prefab Folder
Last modified 1yr ago