Last time we had a look at the character AI beind the scenes of DNFC. We'll expand on that a little further today and talk about behaviour trees. We use modified trees for different character types, namely employees, customers and attackers. Some are shared by all like death sequences, and some are unique like shift patterns for employees.

Certain behaviours, such as “needs” are removed entirely for attackers; we didn’t want them to start dying of hunger or wetting themselves mid attack, as funny as this is, surely they would have sorted themselves out before arriving guns blazing.

You will notice lots of characters walking the streets, some are customers using the complex behaviour trees and some are very simple pedestrians with no behaviour tree - simply walking between two buildings to help fill out the streets. This allows us to reduce the number of complex characters in the world, yet make the world feel just as lived in.
When the player creates a business, complex customers for that specific business are spawned in nearby buildings and walk directly to that business. This allows us to easily control customer numbers based on the business’ rating. As the player builds more businesses more complex customers are spawned; we start to reduce the number of simple pedestrians in the world so the total number of characters in the world stays roughly the same.
This decision is made when a simple pedestrian arrives at their destination, despawning them if the current total has exceeded a threshold. If however they are not despawned, they are instead teleported to a random building in the map and given a new destination to walk to. This is another little performance saver as we don’t even have to remove the character from the scene only to make a new one on the very same frame.
We hope you enjoyed that insight into the inner working of our many pedestrians!
Wishlist DNFC
Join us on Discord!