Send Event to C# script failing

AntL

Member
Hi there, wonder if you can assist with probably quite a basic mistake. I'm attempting to send an event (FreezePlayer) to a C# script which is on BespokeGameLogic gameobject:
SendEvent.png

The code is failing at the only place it can within SendEvent.cs:
Code:
            if (m_ResolvedBehaviorTree == null) {
                return TaskStatus.Failure;
            }

Which seems to imply it can't find the behaviour tree, but this is correct as I'm trying to send that event to a script which is listening for it (not a behaviour tree). Can you advise me where I'm going wrong?
Thanks!
 
Hi, looking at TargetBehaviorTreeAction.InitializeTarget(), it looks like tasks inheriting from this class try to get the or several Behavior Tree components attached to the target object, or the one the tree is attached to if the field is empty. It is apparently not meant to be used on an object with just a standard script listening for the event, but instead to be used in pair with a Has Received Event task. If you want to make a more generic use of Opsive's event system in BD you can use the Execute Event task from the UCC integration, which doesn't feature any parameter, or you can write your own custom task. Hope all of this is helpful !
 
Hey thanks for the reply. Yeah that's what I thought - it's expecting a behaviour tree. Strange though, if you look at the docs it really sounds like a script should be able to listen for this event? Hence the confusion!

You are also able to receive events from outside the behavior tree. To continue with the “MyEvent” example, you can receive this event by using the EventHandler.RegisterEvent method. EventHandler.UnregisterEvent will stop listening for that event.

https://opsive.com/support/documentation/behavior-designer-pro/events/
 
Back
Top