Considering I understood correctly, this is actually pretty easy to do 🙂
The BehaviourTreeOwner (or any GraphOwner for that matter), has a “StartBehaviour” overload that takes a System.Action<bool> argument as a callback. As such, when (for any reason, even by the included ControlGraphOwner action task) the behaviour is stopped, the callback will be called. For example:
1
2
3
4
5
6
7
8
9
10
voidExample(){
varowner=GetComponent<BehaviourTreeOwner>();
owner.StartBehaviour(OnStop);
}
voidOnStop(boolsuccess){
Debug.Log("The behaviour has stopped");
}
Thus the “trick” here, is simply to provide a callback when the behaviour starts. Ending the behaviour can be done in any way and the callback will still be called.
Please let me know if that works for you.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.