To detect input from the various devices, namely, computers and mobiles (iOS and Android), we will make use of the Unity class named Input
with its functions and variables.
For movement-based input, we make use of the Input.GetAxis()
function to ensure that movement is smoother and to reduce the size and complexity of the script.
For all other action event buttons, we make use of the Input.GetButton()
function. We always call these functions from within the Update()
function since they only get reset when the frame updates.
For iOS and Android mobile devices, we can track multiple touch inputs using the Input.touches
property. We can also track input via the accelerometer and gyroscope using the properties Input.acceleration
and Input.gyro
respectively.