This document is about: QUANTUM 2
SWITCH TO

Input


Available in the Gaming Circle and Industries Circle
Circle

Overview

Unity

On the Unity side, the Arcade Racing Sample uses simple polling via the old Unity input system. The implementation can be found in GameplayInput.cs.

Quantum

Input Struct

The Quantum input struct is extremely compact and only contains one byte and one signed byte:

  • Byte Flags are used for a compressed representation of button actions (accelerate, decelerate, nitro, horn, hand brake); and,
  • SByte Steering is used for an analog representation of steering. Unity’s horizontal input axis float (-1 to 1) mapped to sbyte (-127 to 127);

Simulation

In the simulation, the input is tied to InputDesires to provide a single entry point for input generated by Players and AI alike.

  1. Input is processed using the helper struct InputDesires (defined in Player.InputDesires.cs) in the Vehicle and Steering components.
  2. InputDesires are filled in by either:
    • a player’s input polled from Unity (see the Player.Update method); or,
    • AI input (see AI.Update method). The AI generates input using the AIHandling asset which can be easily swapped to further alter the AI's behavior.
Back to top