The Great Fleece Development Recap (Part 2)

Recently I completed the 2nd project of my GamedevHQ course, The Great Fleece. I’d like to talk a bit more about its development.

The Guard AI Waypoint-Patrol System:

Read Part 1 and 2 here.

In this project, I needed a way for the guards to walk back and forth along a predefined route which included n-number of mid-points at which the guard would pause. A common solution for this kind of requirement is a waypoint system for the guards to path-find to, which is what I decided to create.

A waypoint path with no alternatives, drawn in green

The system simply uses a list of world positions and a Unity Navigation NavMeshAgent component to allow the guard (or any entity) to path-find to each point. Using variable timers and options, I can choose how the patrol behaviour functions.

For some of the guards, I also needed the ability for them to walk to one-of-two waypoints randomly, to add some diversity to their patrols. For that, I gave each waypoint an optional “Alternative” point.

Waypoints with an active “Alternate” are drawn in blue

For easy development, I made the patrol component draw lines between each point. Green between no-alternative points, blue when one-or-more points has an active alternate. Finally, the red lines with the dot-end are the direction the guard will turn to at that point, and the red lines over the blue are the zone in which the guard will start turning prior to reaching the point (for smoothness).

Player Movement/Navigation:

Read more here.

The Player navigation/movement code is pretty simple. It just uses a raycast from the camera to the point where the mouse clicked (if a valid layer is there) to determine the destination. It then uses NavMesh.SamplePosition to find the closest valid NavMesh point near the mouse click (this ensures that the player avoids walking into walls or display cases. Then it uses the Unity Navigation system, like the guards, to path-find to that point.

Using the NavMeshAgent’s path while walking and a LineRenderer, I create an accurate line showing the path that the player will walk to the destination. I also enable a small 2D plane with a PNG marker and set its position to the destination.

Path and destination marker

--

--

--

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

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

Recommended from Medium

Why should start-ups choose Ruby on Rails for Web Application Development?

How to work with the topology of Star data models in Qlik Sense, and not bury yourself.

A Buffet of Specialized Data Types — Real Python

A Buffet of Specialized Data Types – Real Python

Is software Darwinism making your business extinct? — its time to reconsider legacy applications!

TryHackMe — Network Services 2

How to solve a linear optimization problem on incentive allocation?

Build a website blocker in Python in few minutes

Export data as an XML file using PowerApps and PowerAutomate

Data transfer image

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

Vincent Taylor

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

More from Medium

Upgrading A Unity Project To The Universal Render Pipeline (URP)

Working with Unity Ads

How to Create A Loading Scene in Unity

Adding a player ammo indicator to the UI