🎮Joystick
Behaviours
Fixed (Pivot point is on touch began position and it's fixed)
Dynamic (Pivot point is on touch began position and it's follows touch movement if it's out of radius)
How to use
Go to Canvas where you want to use it, usually it's GameCanvas
Replace joystick prefab in Canvas by Create asset menu in hierarchy. Right mouse click on Canvas -> Core Prefabs -> Joystick. Or you can drag and drop in from _Main\Prefabs\UI\Joystick.prefab
To avoid Joystick appear on UI elements such as buttons -> Replace Joystick on top of other UI elements so it wont be triggered, because other elements will cover Joystick touch zone.
Here is screen example of hierarchy with correct joystick hierarchy position:

To change visuals, open Joystick.prefab and there is Stick and Background objects. You can freely change their sprites.
Reference Joystick in script where you need it. For example in Player.cs declare variable of Joystick type.
To change radius and other settings of Joystick
-> go to _Main/Configs/Joystick Settings.asset
- [Joystick radius] is background sprite half-size, bigger radius -> player need to move touch farther to reach full movement coefficient; - [Stick sprite radius] is stick sprite half-size, only visuals change; - [Default Joystick Behaviour] <- what behaviour will be by default (you implement setup by SaveData.cs and JoystickBehaviours enum if you need toggle and save it yourself); - [Render Joystick On UI] <- should be joystick sprites visible on active state?
You can toggle joystick enabled state by IsEnable property. Useful when you need to lock player input for a while.
You can switch behaviours (Fixed-Dynamic) runtime using SwitchBehaviour() from Joystick object.
Example of usage in _Examples/PlayerInput/Joystick/Joystick.scene
Last updated