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, with the position of the tap/click being the location where the finger has been pressed. This form of input provides just the position where the touch happened and that it happened; it doesn't give you all of the features that the mobile-only options do. We will be discussing all of the features you get using mobile-specific input later on in this chapter, but I think it's important to note how to have click events on the desktop as well. I personally use the desktop often for ease of testing on both the PC and on my device, so I don't have to deploy to a mobile device to test every single change made in the project.
The following steps show how to use the desktop-based mouse click events for movement of the player:
- Inside Unity...