Input
Available in the Gaming Circle and Industries 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.
- Input is processed using the helper struct
InputDesires
(defined inPlayer.InputDesires.cs
) in theVehicle
andSteering
components. 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 theAIHandling
asset which can be easily swapped to further alter the AI's behavior.
- a player’s input polled from Unity (see the