I am wondering how I could do stuff based on which actor is currently running the tree…? For example, if I want Actor A to do a task which only Actor A can do, how would I go about this with a decorator? Currently I did some testing/super unoptimized stuff to see if I could do this. I created a decorator like this:
It simply checks if SelfActor BB key is equal to the ones I’m casting to. However, it returns only a boolean so I do not know how to check which is which and act accordingly. How can I go about this?
Do I have to switch Behavior Trees for this? Is there any way I can achieve what I want using only one master tree?
Hi, generally speaking I would say just don’t do it like that, cause from your description it sounds like something that will grow unmaintainable really fast
Is there any way I can achieve what I want using only one master tree?
I am wondering how I could do stuff based on which actor is currently running the tree…?
Generally I would try to keep things modular and reusable. If you try to put everything in one single behavior tree, all those things will depend on each other (e. g. if you want to remove something or add something you need to keep the whole tree in mind and might make changes at several points).
From a behavior tree you can run a subtree, so if you need different behavior per actor, then you could use one behavior tree for each of them. And if you use the same behavior often, you can put that into a separate behavior tree and then just run that behavior tree.
One thing behavior trees generally seem to lack though, is a clean way to model multiple behaviors (e.g. in your behavior tree you have a decorator for whether the target is set and things like that will add up the more behaviors you add).
Another node I often find useful is ‘SimpleParallel’ here Behavior Tree Overview | Unreal Engine Documentation under ‘Simple Parallel Nodes’. Those enable you to run two things at the same time (like e.g. fire at target and keep facing target)
And I generally found this here useful for getting a feeling where behavior trees stand in the whole system AI Arborist: Proper Cultivation and Care for Your Behavior Trees - YouTube, from about minute 19 to 39. Afterwards I more or less implemented my own state machine in c++ and now use that combined with behavior trees (now in ue5 it seems like they added a system called StateTree, but I haven’t tried that so far).