I am referring to part of the Nodecanvas documentation called “Runtime Instantiation Tips”
I found that segment when I was trying to start a behavior tree at runtime and switching FSM at runtime, however everything explained in there is if you do it by coding
I would like to suggest to add the same documentation but using Action tasks
here are the marked segments marked(*)that would be helpful to have explained in Graphical way by Action Tasks in FSM or BT
“…
(*)Option 1
You have a game object prefab with a BehaviourTreeOwner. You also have a created BehaviourTree.
At runtime you can instantiate the BehaviourTreeOwner game object prefab …
(*)Option 2
You only have a BehaviourTree created and no BehaviourTreeOwner at all. You can add the BehaviourTreeOwner component at runtime and similarily to above, Start a new graph for them…
(*)Of course in most cases you will also want to assign a blackboard for the BehaviourTreeOwner to use.
Going Further
(*)Using the StartBehaviour(Graph) or SwitchBehaviour(Graph) you can go further and even switch BehaviourTrees at runtime.
(*)While this is quite possible, it is best design wise, to have only ony BehaviourTree and switch behaviours within using Nested Behaviour Trees.
All the above examples are also true for State Machines as well….”
Most of those things could be done with creating very simple custom tasks based on the code shown in this documentation section. For example, here are two action tasks to SwitchBehaviour of a GraphOwner (BehaviourTreeOwner or FSMOwner respectively).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
usingNodeCanvas.Framework;
usingParadoxNotion.Design;
usingNodeCanvas.BehaviourTrees;
usingNodeCanvas.StateMachines;
namespaceNodeCanvas.Tasks.Actions{
[Category("✫ Utility")]
[Description("Switch the entire Behaviour Tree of BehaviourTreeOwner")]
[Description("Switch the entire FSM of FSMTreeOwner")]
publicclassSwitchFSM:ActionTask<FSMOwner>{
[RequiredField]
publicBBParameter<FSM>fsm;
protectedoverridevoidOnExecute(){
agent.SwitchBehaviour(fsm.value);
EndAction();
}
}
}
Let me know if that is indeed what you are after. If so and you need more tasks to perform different things stated in that section, let me know what that is, and I can provide them.
Thanks