🎮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 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.

Main properties of Joystick object in script:

  • MoveCoef [0..1] returns how far player moved finger from joystick center, where center is 0.

  • MoveDirection is result direction on plane XZ.

  • Movement is MoveDirection * MoveCoef

Example of usage in _Examples/PlayerInput/Joystick/Joystick.scene

Last updated