Zenject + Behavior Trees + FSM

As we set out on an adventure for a new game idea I’ve decided to waste a lot of time building a future proof frankenstein of a framework mashup.  Is that possible you say? Future proof? In my experience I can honestly say no its not but we’re gonna give a try!

Our mashup is going to include a popular DI framework Zenject, along with a custom built state machine that resembles ideas behind the building of Pokemon Go in this talk, but also includes full control over the game flow by inserting custom behaviors using Behavior Designer. Does this mean that you need to buy Behavoir Designer? No, we have a class that can be used as a Facade and will be completely interchangeable if you want to use a different open source library such as this Fluent Behavoir Tree.

One of the main benefits of using this architecture is to increase productivity by being able to launch any state within the game under any circumstances, all while having the ability to tweak and save changes to scriptable objects or prefabs.  It will also serve us well when it comes to game flow and asynchronous events that can sometimes fly out of control if you’re developers don’t stick to a strict interface. Everything in this framework is state based, under your control and under the control of our main StateController and behavior trees. This will prevent those scenarios that drives me nuts! Like when you’re in the middle of game play on the train and intermittently get 1 bar of service. All of a sudden a Daily Bonus Screen pops in your face and completely breaks the app and your willingness to keep playing! Amateur. But we’ve all been there right? You don’t understand these complex issues unless you’ve experienced the pain that comes with them. But it’s OK, we’ve solved that for you. In our framework, we steer away from your Daily Bonus Screen just being an observer, ready to pounce as soon as you get that message from the server. Instead, we allow states to transition and decide whether or not its an opportune time to present someone with their daily bonus.  Perfect time to bring on the behavior tree! We could create a sequence that runs when transitioning from GamePlayState -> NextLevel that checks whether or not the Player has a daily bonus first and then we can get fancy and say lets show the daily bonus only if the player just got a bad score to lift up their spirits!

I will add to this article soon and possibly share some examples if you’re interested in what we’re doing. Until then, go out and get yourself a quality meat sandwich! And don’t fall for that $3 fontina cheese. It was already perfect.

Leave a Reply

Your email address will not be published. Required fields are marked *