Nerd For Tech
Published in

Nerd For Tech

Waypoint-Patrolling AI With Branching Paths In Unity, Part 2

For my stealth project, I had to make patrolling guards. However, I decided to mix it up with some randomly-selected alternate paths, and a “look direction”.

The guard randomly chooses an alternate waypoint position to go to, when enabled.

The code:

This randomly chooses either the Primary or Alternate Waypoint as the destination.

Drawing all the Scene View debug lines:

The result:

Although he does seem to like 1 path in particular in this test, each Primary/Alternate selection is a 50/50 chance.
Here you can see all the Waypoint “Primary”s, and their “Alternates” if enabled.



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
Vincent Taylor

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