Point & Click to Move in Unity

In the current project, I’m doing which has a stealth element, we move by clicking the ground / Point & Click

Let’s start simple… We can simply create our Point & Click with Unity’s Navigation system also called NavMesh.

Baking The Floor

  1. Open your Navigation tab from Window -> AI -> Navigation
  2. Select the Ground Object and in the Navigation Tab click Bake

If you have your Gizmos on you should see that the ground’s color is blue

Making the Player move (with NavMesh and Raycast)

To make the player move we add a simple script to it and we use Raycast to define where we click with the mouse, then we take the position and use SetDestination to move our player to that position.

Before you do these steps, add a NavMesh Agent to your Player

  1. Create script and attach that to player (I created a simple “Player” script)
  2. We need a handle for our NavMeshAgent
  3. And set our Raycast

4. We create a method that we call when we want to move to the position which we just clicked.

  • We set up the ray
  • If we hit something with the ray, we move the information using out, to our hit
  • Then inside the if statement we use SetDestination to make our agent’s new position to the hit.point. Which is the position we just clicked.

And in the update function, we call this method when we click.

And this is how we create a simple Point & Click with Unitys Navigation system. I hope this helped you on your coding/game dev journey! :)




From the beautiful snowy country with a touch of "good" humor? Inspired Unity Developer to learn more.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to run API automated tests with Newman on CircleCI.

Deploying Tornjak with Helm Charts

Python Function Guide: Day 8

When you’re accused of sabatoge…

A Back-End View of Front End Web Design

Creating A Basic Loot Table For Power-Ups

Using Web Element Locators in Test Automation More Effectively

Leading DeFi Options Protocol Asteria Reach A Strategic Partnership With DeFi Borrowing/Lending…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Janika Suhonen

Janika Suhonen

From the beautiful snowy country with a touch of "good" humor? Inspired Unity Developer to learn more.

More from Medium

Did you just hit me! — Hitbox attack system in Unity2D

Loading Scenes In Unity

Switch Statements to the Rescue

Making Moving Platforms In A Unity Platformer