How good is the idea to use behavior tree for player movement?

2.2k views Asked by At

I develop a game with Unity. Now I implement a player parkour (movement) system, so I try to choose pattern that will help me to keep architecture clean in the long term and easily add new states. I tried to use state machine pattern, but I realized, that it grows more and more.

So I gave up on this solution and decided to use behavior tree pattern. But now I'm starting to notice, that this architecture is going deeper and deeper and conditions for parallel states become difficult to control. I think this is not a best way to create player parkour (movement) system.

So my question is: is there a better way to create player movement system and how hard will it be to work with the behavior tree? Maybe there are pitfalls in behavior tree that I didn't notice? I'm searching for architecture, that let me perform parallel states (or analog) by conditions and will be easily maintained.

My prototype now looks like this (don't pay attention to get keys, it's just a quick plan for architecture):

2

There are 2 answers

4
Pino De Francesco On BEST ANSWER

A behavioural model encoded with Behaviour Tree is too strict and will get you in trouble quite easily. An FSM (Finite State Machine) is the simples and yet more complete and flexible architecture for any part of a game. A Behaviour Tree can adapt to simple brain functions typical of NPCs but definitely not to a human-driven player.

0
Sunny Sun On

there is a very good article for you to understand deeply about Behavior tree. Behavior tree is superior to FSM at all aspects. it is scalable and easily readable logically. https://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php