Hey everyone!
Time for another dev diary post and we're diving into what makes the characters tick!
When the world of Definitely Not Fried Chicken is in full motion, the map will be filled with hundreds of complex characters navigating and participating in the world; from visiting player businesses to walking the streets.
Characters must react to their “needs”, respond to alerts such as fires or attacks and keep tabs on what work is available if they’re an employee. In order to do this we’ve utilised behaviour trees to give structure to the priority in which tasks are executed.
For example, if an employee is desperately hungry they will prioritise making a sandwich over doing work. If an attacker were to burst through the door at this very same moment however, the employee would forget about the sandwich and run away from the attacker. While running away, if the employee’s bladder stat reaches zero, they would then pause to wet themselves before continuing to run away. The poor guy just wanted a sandwich...

Behaviour trees allow us to more easily create these complicated behaviours, although it certainly isn’t trivial given the range of possibilities; resulting in large trees with many branches.
In terms of performance we couldn’t run such complicated behaviours for every character every frame. So we spread the computation over a number of seconds resulting in a few trees being updated every frame.
This works well as we don’t mind if there’s a slight delay in the character's realising they need the toilet for example. Other scenarios might demand more instant reactions such as gun battles, in which case we update a character’s behaviour immediately after they’ve been killed so we get their death animation to play without a delay.
Thanks for reading and we'll see you next time!
Don't forget to add DNFC to your wishlist & join us on Discord!
