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:
Then, in my ability, I execute the event:
This is my OnPickupInjectable function:
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?
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?