Triggering Events from Code and Parameters

..Tom..

New member
I've got a similar issue to https://www.opsive.com/forum/index.php?threads/event-system-examples.4221/ but couldn't fix it with the answer there nor the examples in the documentation.


I am trying to build a behavior where the AI continues with a given task until it receives an event to start a new task. Each task is a tree with conditional abort, like this:

Bildschirmfoto 2021-12-07 um 09.06.24.png


I'm trying to execute events, i.e. switch to the relevant branch, by sending an event and some parameters, which differ per branch, like this:

C#:
            behaviorTree.SendEvent<object, object>("StartTask", (object)spot.gameObject, (object)"walking");

The HasReceivedEvents never go green. I've tried without the explicit cast as well. I've tried sending the event inside the tree using the SendEvent task and that works. What am I doing wrong?
 
I've re-written the tree using conditionals instead, which works for me. I wonder though which solution is better? Using events as I try above, or using conditional evaluators like this:

Bildschirmfoto 2021-12-07 um 11.26.19.png
 
Top