Touch Joystick Icon

Touch Joystick

1. Introduction

Welcome to the Joystick Touch solution. This provides a comfortable and modular on-screen joystick for Unity. It simplifies the implementation of touch joysticks with full support for Unity’s New Input System.

2. Installation & Basic Requirements

  1. Activate Unity Input System
    • Installation & Requirements
    • EventSystem
      • Ensure an EventSystem is present in your scene. If missing, add one via Create → UI → Event System.
    • Import Asset
      • Import all scripts from the New Input System Pro asset into your Unity project via the Package Manager in My Assets.

3. TouchJoystick: Define and Create a Touch Joystick

Use the TouchJoystick component to create responsive on-screen joysticks that support different modes and input systems. It can be used with Unity Events, the Input System, or via API.

3.1 Setup

  • Create a UI hierarchy with a background image and a handle image inside it.
  • Add the TouchJoystick script to the root object (in this example the JoystickLeft Gameobject).
  • Assign the Handle Transform and Background Transform in the inspector.
  • Assign a Joystick Area to limit the touch zone.
Screenshot: Configuring Input Actions

3.2 Joystick Settings

Screenshot: Configuring Input Actions
Field Description
Joystick Identifier Unique name for this joystick instance. Required for API usage.
Joystick Control Path Path to send values to the Input System (e.g. <Gamepad>/stick).
Sensitivity Quantizes output. Higher values give smoother input resolution (the lower the better for performance).
Joystick Mode Defines how the joystick behaves:
- StaticOnly: fixed on screen
- Dynamic: appears where touched
- Mixed: visible but touch start can be anywhere in the area
Ignore UI Element Allows touch input through UI elements (e.g. if joystick overlaps buttons).
Always Forward / Always Forward Start Forces Y axis to stay at 1.0, optionally activates this at game start.
Enable X/Y Axis Allows movement on the corresponding axis. Can be used to restrict input.
Invert X/Y Axis Reverses input on the selected axis.

3.3 UI Assignments

Assign the necessary UI elements to control the visual representation and behavior of the joystick. All transforms must be set correctly for full functionality.

Screenshot: Configuring Input Actions
Field Description
Handle Transform The inner element that moves. Must be a child of the background object.
Background Transform The base visual that remains static or repositions (in dynamic/mixed modes).
Joystick Area Optional RectTransform defining where input is accepted (used in dynamic or mixed mode).
Movement Range Maximum distance the handle can move from the center (in pixels).

3.4 Input and Output Methods

Choose how the joystick should send its input: via Unity Events, the Input System, or the API. All methods can be used independently or in combination depending on your setup.

Screenshot: Configuring Input Actions
Option Description
Use Unity Events Triggers onJoystickPressed and onJoystickReleased UnityEvents in Inspector.
Use Input System Sends button values onJoystickPressed and onJoystickReleased to assigned Input System ControlPaths.
Use API Broadcasts joystick input through JoystickOutputAPI (value, press, release).
Action Mode Determines how press/release actions behave: Trigger, Toggle, ToggleOn, ToggleOff.
Pressed/Released Control Paths Optional paths to trigger actions when joystick is pressed/released (Input System).

3.5 Debugging

Enable these options to log useful runtime information while developing or testing joystick behavior.

Screenshot: Configuring Input Actions
Option Description
Debug Stick Movement Logs the current output value of the joystick each time it updates (Vector2 normalized).
Debug Joystick Events Logs press and release events in the console (without screen position).