Hey eyeballs!
In our RPG mixed with management/automation game “COCOA“, we played as two main opposites: Issa and Asante, two child laborers in South Ivory, and Mr. Theodore, a greedy businessmen who tries to expand his chocolate business.
When we play as child laborers, there’s one thing that must be present… guards, of course! Well because if there’s no guards supervising the child laborers, the children probably won’t be disciplined enough to work inhumanly by themselves, which won’t make them marked as laborers.
So, we have to add guards!
These guards will do two simple things
- Patrol the map
- Chase the player
Patrol the Map
The map for our child laborer section is planned to be HUGE, since it’s a game about trying to find new areas while being chased down. So we need some smart AI’s.
We do this by firstly adding pathfinding to our AI’s. We use arongranberg’s A* pathfinding so the guards can find the most effective route when chasing the player, since the paths are intricate and have lots of turns.
At first, things were… questionable.
But it all works out in the end!
Second thing is to implement the patrolling system using this pathfinding. So how it works is when the player is not doing the right activity with the current schedule, the guard will select one out of many configured points and go there. Once they reached one of them, they will wait for a couple of seconds before picking another point and go there. The whole point of this is to search the player when they he isn’t working. But when the player is in the right activity, the guards will stop patrolling and wait in a specified point in the map.
(Each red blob represents a guard, and the green line is their pathfinding.)
Chase the Player
A guard who’s previously patrolling will chase down the player if it appears on the player’s screen. When that happens, an exclamation mark will appear and they’ll wait a few seconds before chasing the player. We want to be honest with you, the chase is pretty terrifying, because you have to decide where to go quickly. Expect some kind of a chase like Ao Oni but with a different tone to it.
Inspired by Ao Oni‘s chase mechanic, though in this game it’s much quicker and have a different tone to it.
You can outrun the guards by doing one of these two things:
1). Hide in bushes
There are bushes scattered across the map where we can hide there. But we must be extremely careful, because if the guard already appears on the same screen A.K.A see us already, they will detect our strategy and eventually pulling us out of the bush.
2). Keep running!
If you keep running and making sure that the guard doesn’t appear on the same screen, they eventually gave up in chasing you. But this is very energy inducing, since you’re going to run for about ~20 seconds.
Behind the Scenes
Making this whole system is a headache, since it’s very complex and requires us to be detailed in every scenario.
It took us about 1 to 2 weeks to make all of the systems, this includes pathfinding, state managements, chase logics, camera detection, and many, many more. But the hardest thing is to implement the player detections. Since the map in this game is pretty big and can have many intricate routes, we must to make sure that the guard’s detection is flexible.
Since we did it in unity, we do so by implementing some raycasts and gizmos.
Final Words
Thanks for reading this blog! Wow.. you’re truly a fan of us :’)
If you have any feedback regarding our guards, be sure to tell us through this feedback form. Though there are already things that we have in mind regarding the AI. One of them is creating a more intense and expressive effects when we’re chased. Nonetheless, you can tell it! Especially how the effects will go and etc.
Be sure to wishlist COCOA on Steam so you don’t miss out when a demo and full release comes out!
Join our Newsletter!
By joining our weekly newsletter, you’ll get access to our latest game progress, behind the scenes, and freebies (game keys, printables, etc), and many more!