Working with Unity’s Nav Mesh System for Smart AI

Objective: Stop the Player walking through and clipping objects.

Following on from the last post, we can see in the above image that our Player is moving on click but is going through and clipping the other GameObjects in the scene. We need to fix this so that the Player goes around the objects.

It’s actually not too difficult to fix. It just means rebaking the scene but with one difference. We need to change the other GameObjects that we don’t want the Player to travel through to static so that the mesh knows these objects are obstacles that need to be avoided.

You will notice the outline or highlighting on all the objects in the scene. These are all the selected GameObjects that will now be set to static and rebaked with the NavMesh. Once these have all been set to static, go back to the Navigation panel and clear the old baked data before baking another one.

The above image is the old NavMesh. As you can see the blue highlighting doesn’t stop near the objects. In fact it passes underneath them.

This is our newly baked NavMesh. As you will notice the blue highlighted mesh stops and leave an area around each of the objects. This is as far as our Player can travel so no more moving through objects.

--

--

--

Developer

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

Recommended from Medium

A Step-by-step Guide to Streaming Salaries With Superfluid on Polygon

System Design — UML Activity Diagram

Building Microservices with AKS and VSTS — Part 4

My file Server(Armour infosec)

The best Datacenter proxies for you

A GUIDE ON HOW TO OUTSOURCE SOFTWARE DEVELOPMENT (2019)

HEROES OF NFT VALUE GENERATION MODEL

A Complete Guide to Python Web Development

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
Simon Leen

Simon Leen

Developer

More from Medium

Using Tessellation in Unity’s HDRP

My approach to optimization

Create a Diablo Style Character Controller in Unity!

Laser Fire Rate