Using mouse input
Before we dive into mobile-only solutions, I do want to point out that it is possible to write input that works on both mobile and PC by 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 indicates that a press has happened; it doesn’t give you all of the features that the mobile-only options do. We will discuss all of the features you have 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 a PC and my device, so I don’t have to deploy to a mobile device to test every single change made in a project.
To use desktop-based mouse click events for the movement of a player, first, inside Unity, open up...