Now, before we dive into mobile-only solutions, I do want to point out that it is possible to write inputs that work on both mobile and PC, namely using mouse controls. Mobile devices support using mouse clicks as taps on the screen, and we can use the mouse position as being where the screen was touched. This doesn't give you all of the features that the mobile-only options do; we will be discussing that later on in this chapter, but I think it's important to note, since I use this often for ease of testing on both the PC and on my device, making it so I don't have to deploy to a mobile device to test every single change made in the project:
- Inside Unity, open up your PlayerBehaviour script and add the following highlighted code to the Update function:
void Update()
{
// Check if we're moving to the side
var horizontalSpeed...