Using Unity’s NavMesh & Raycasts — How To Move a Player By Mouse!

Let’s see how to do some click-and-moving :)

Mina Pêcheux
CodeX
Published in
6 min readSep 11, 2024

--

This tutorial is available either in video format or in text format — see below!

Project Overview

Ok so: let’s say I have this basic Unity project with a 3D character, a ground plane and some walls.

Now, I want to add some movement to this character so that, whenever I click somewhere on the floor, my character automatically walks towards it and avoids the walls if need be.

To do this, I’m going to rely on two nice Unity tools: the built-in navigation system and the raycasts.

Using Unity’s Navigation System

--

--

Mina Pêcheux
CodeX
Writer for

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)