Point and click movement is one of the most elemental types of player input in a game. In this tutorial we’ll cover setting up and coding a simple point and click mechanic to get your players exploring the world.
Let’s start by opening a new (or existing) project in Unity. Put a down a simple plane object to act as our floor and then a Cube to represent our player. You may need to adjust the Main Camera to look down at the objects.
Create a new script named “ClickMove” and add it to the Cube object. This will drive all the functionality of the mechanic. We’ll go over it below.
There you have it. A simple but effective point to click movement system. This is what it looks like in action.
The beauty of this code is the extensibility and ease of understanding. It does have some limitations that do need to be worked around such as using layers to avoid clicking on obstacles but this should be a good foundation to getting started. Until next time, happy coding.