For me, it makes sense to use an FSM for my root AI logic as the FSM would dictate what behaviours they are able to perform. To do this, it seems like I would want to have my FSM states control which sub-BT should be evaluated at any given time. What is the intended way to change which BT is evaluated when I enter / exit a FSM state?
(I now realize this is probably the incorrect forum to post this but oh well)
If you are using an FSM as the root with sub-BehaviourTrees (which is what I also prefer by the way), then each sub-BehaviourTree is actually a state of the FSM. Therefore, the current sub-BehaviourTree state is the one that will evaluate.
Please let me know if I misunderstood your question.
That makes sense, however, if each sub-BT is a state, then how do I store other state-related information along with it? For example, let’s say I have an Aggro and Passive state, conceptually. Perhaps, in the Aggro state, I would want to store some encapsulated data like which target the AI is aggroed to, but I do not want to store that information in the Passive state. This alone would be easily possible with a normal FSM as each state can hold whatever it wants. But when I try to combine this normal state behaviour with a sub-BT, I realize that the sub-BT and the actual state (like Aggro or Passive) would be considered separate states.
So, to summarize, I do realize that using sub-BTs as states could achieve part of what I want, but how do you associate data with those specific states? Is there some way to “link” multiple states together so I can store data and execute specific behaviour?
To better illustrate what I want, I will explain a scenario that would work, but feels wrong. I could use a normal FSM with normal states, and each state could have an inspector-assignable sub-BT. Then, when any state is entered, the state assigns its sub-BT as the “current” BT to be evaluated. To do this I would need one parallel BT that is always being evaluated, and it just gets swapped out.
Each graph in NC has its own local variables. Therefore data can be associated with a BT-state by creating and using local variables in that BT graph, and by optionally mapping those local variables from/to variables of the parent FSM graph to get/set those variables when the BT-state enters and exits. Here is the Docs section regarding variables mapping for your convenience.
Regarding your example in the last paragraph, I am not really sure what you mean :(. A BT added in an FSM, IS the actual state itself, so you don’t have to swap in and out BTs. You just have to create two BT states (eg Aggro and Passive) in your parent FSM, and of course make the transitions that you would like the FSM to have.
Let me know if that is what you meant. Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.