Simple Click To Move In Unity

First we need to add a Nav Mesh Agent component to our player, which will allow our player to move along a surface.
Next we have to actually bake our nav mesh on our walkable surface. This should work so long as your object is set to Navigation Static.
Once the game objects are ready, it’s only a few lines of code to get click to move working. Just a ray cast from the mouse pointer position to get a destination, then set the navigation to work.

--

--

--

Game developer with over 12 years of experience, mainly focused on MMOs.

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

Recommended from Medium

[Java]小作品-訂單管理系統

Let’s get Moving! : Simple Movement in Unity

How to create a lab environment like a production?

Building a Video Sharing Website: Part 2 Index Page and Authentication

Deployment of Application on Kubernetes

Alvin’s Dew Drop Daily — Issue #154

Day 2: Advanced Git Features!

Weekly Dev Stand-up — Mar 25, 2018

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
Ben Pielstick

Ben Pielstick

Game developer with over 12 years of experience, mainly focused on MMOs.

More from Medium

2.5D Platformer: Moving Platforms

Unity : AI [Navmesh implementation (Part II)]

Quick tip — Upgrading your Unity project to Universal Render Pipeline (URP)

Building A Stealth Game — Creating Security Cameras