Showing AI Navigation Path In Unity

I was playing my stealth top-down click-to-move game, and decided to add a subtle indication of the path the player character would walk.

Vincent Taylor
2 min readNov 16, 2021

Today’s Objective: Use a Line Renderer to subtly show the path that the player character will walk when moving, making navigation feel a little safer.

The Setup:

Since the actual movement code has already been completed in a previous post (Point-And-Click Movement), this one will not contain too much.

First I create a GameObject in the scene which is simply a 3D plane. I find a nice texture to be the icon, and create an Unlit Transparent material for it.

After disabling that GameObject (since it should only be active when the player is moving), I add a Line Renderer component to the Player object and set the line width to 0.1, material to “Default-Line”, and color to grey.

Now for the code:

Find and store the attached Line Renderer
Update the line path and destination icon

The Result:

I think it looks great, and gives just enough indication to not be too over-the-top.

--

--

Vincent Taylor
Vincent Taylor

Written by Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

No responses yet