How our Guard AI’s Track You Down in ‘COCOA’

COCOA

Plot an escape as a cocoa bean child laborer or expand a ruthless chocolate factory tycoon. Switch between stealth-RPG and management as the story progresses. Process cocoa beans, evade guards, or place machines and upgrade factories. Experience a moral dilemma between greed and humanity.

Hey eyeballs! [img]{STEAM_CLAN_IMAGE}/45185261/cd963f3712e6109eb19ab689a41eeb434709c4d2.png[/img] In our RPG mixed with management/automation game [url=https://store.steampowered.com/app/3180660/COCOA/]“COCOA“[/url], 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! [h3]These guards will do two simple things[/h3] 1. Patrol the map 2. Chase the player [h1]Patrol the Map[/h1] [img]{STEAM_CLAN_IMAGE}/45185261/ae0d4fc606f90aecf517f75a1f328b67311c194a.gif[/img] 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. [img]{STEAM_CLAN_IMAGE}/45185261/7807eff47c867e4f40272b64e3eaccc90c09f8f0.gif[/img] 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. [img]{STEAM_CLAN_IMAGE}/45185261/360e0146913978a6d3cdcfa5f8d12326102142c2.gif[/img] [i](Each red blob represents a guard, and the green line is their pathfinding.)[/i] [h1]Chase the Player[/h1] 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. [previewyoutube=poRctR59Q7k;full][/previewyoutube] [i]Inspired by Ao Oni‘s chase mechanic, though in this game it’s much quicker and have a different tone to it.[/i] [h3]You can outrun the guards by doing one of these two things:[/h3] [b]1). Hide in bushes[/b] [img]{STEAM_CLAN_IMAGE}/45185261/489861d94a69d3be687c348e7787a669b42157f4.gif[/img] 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. [b]2). Keep running![/b] 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. [h1]Behind the Scenes[/h1] 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. [img]{STEAM_CLAN_IMAGE}/45185261/1d8f5b3b411e7d9ef924b13ea48edbf6f3478236.png[/img] [h1]Final Words[/h1] 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 [url=https://store.steampowered.com/app/3180660/COCOA/]wishlist COCOA on Steam[/url] so you don’t miss out when a demo and full release comes out! [img]{STEAM_CLAN_IMAGE}/45185261/cd963f3712e6109eb19ab689a41eeb434709c4d2.png[/img] [h1]Join our Newsletter![/h1] [img]{STEAM_CLAN_IMAGE}/45185261/47160a3b1dee06c924f4e9690ecce0951be316c5.png[/img] By joining our [url=https://pupilentertainment.com/newsletter/]weekly newsletter[/url], you’ll get access to our latest game progress, behind the scenes, and freebies (game keys, printables, etc), and many more!