Do EventHandler.RegisterEvent(...) work inside a Behavior Tree Task?

airoll

Member
Hi, I am trying to register an event handler using the Opsive.Shared.Events system from within a behavior tree task. I register it using the following code within my custom Action task:

Code:
EventHandler.RegisterEvent<InjectablePickup>(m_GameObject, "OnPickupInjectable", OnPickupInjectable);

Then, in my ability, I execute the event:

Code:
EventHandler.ExecuteEvent<InjectablePickup>(m_GameObject, "OnPickupInjectable", injectablePickup);

This is my OnPickupInjectable function:

Code:
        private void OnPickupInjectable(InjectablePickup injectablePickup)
        {
            Debug.Log("Picked up injectable.");
            ...
            EventHandler.UnregisterEvent<InjectablePickup>(m_GameObject, "OnPickupInjectable", OnPickupInjectable);
        }

However, the OnPickupInjectable function is not called. I'm not sure why. I checked that the m_GameObject was the same for both the RegisterEvent and ExecuteEvent. Does RegisterEvent not work inside of a behavior tree task?
 
It should - the character controller integration does something similar with the OnDamage task. Maybe your event isn't being registered?
 
Top