A different approach would be to use a action task to do the same thing. The only thing would be better if the BT is cloned or instantiated so that multiple agents can use the same BT.
I use similar approach for FSM for dynamic FSMs.
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
usingUnityEngine;
usingSystem.Collections;
usingNodeCanvas.BehaviourTrees;
namespaceNodeCanvas.Actions{
publicclassBehaviourTreeAction:ActionTask{
[SerializeField]
privateBehaviourTree _behaviour;
publicBehaviourTreebehaviour{
get{return_behaviour;}
set
{
_behaviour=value;
if(_behaviour){
_behaviour.agent=agent;
_behaviour.blackboard=blackboard;
}
}
}
publicboolrepeatBehaviour=false;
protectedoverridevoidOnExecute(){
behaviour.runForever=repeatBehaviour;
behaviour.StartGraph(agent,blackboard,EndAction);
}
protectedoverridevoidOnStop(){
behaviour.StopGraph();
}
}
}
Login
Register
By registering on this website you agree to our Privacy Policy.