Great Fleece | NavMesh AI in Security Guards…!!

Anurag Chawla
2 min readOct 14, 2021

--

To add functionality in Security Guards to move intelligently using NavMesh Agents

NavMesh Agent — along with WayPoints
Security Guard -Prefab

These NavMesh Agent added along with the WayPoints System — that adds the functionality of AI in the Security Guard.

Here three waypoints are shown in inspector Point_A, Point_B & Point_C inside the empty GameObject WayPoints these are done through C# API Scripting via defining the variable as below.

public List<Transform> WayPoints.

The three positions of the Security Guard are set at the transform component for each of them (Point_A, Point_B & Point_C)— so that the security guard will start at Point_A (current target =0 )then move to Point_B then to the final destination Point_C following the NavMesh before returning using the below logic.

Script — GuardAI .cs

A coroutine is called waitBeforeMoving() so that the security guard will idle at each of the positions before reaching the final destination and repeat the same process while moving back from the destination to the original position.

Script — GuardAI , Coroutine -WaitBeforeMoving()

Finally, the final AI movement of the Security Guard…!!

NavMesh AI @ Security Guard

--

--

Anurag Chawla

Emerging Technologies - Power Virtual Agents | AI Chatbots | Multi-Cloud & DevOps | UI Technologies - React , Angular | Gaming Technolgies - Unity, XR- AR/VR