I have encountered unexpected behavior using events provided by reference variables. If a reference is set within the editor, events linked to that reference behave as expected. If a reference is set at runtime, the same events exhibit unexpected behavior.
To demonstrate, I have an Actor, RefEventTester. RefEventTester has an Actor reference type variable, ActorRef. RefEventTester uses ActorRef’s OnDestroyed event to execute some behavior.
RefEventTester is placed in a level with ActorRef pointing to some other Actor in the level. ActorRef’s Actor is destroyed, successfully triggering RefEventTester’s OnDestroyed(ActorRef) event. During runtime, ActorRef is changed to point to another Actor in the level. ActorRef’s new Actor is destroyed, but does not trigger the OnDestroyed(ActorRef) event.
In an alternate scenario, RefEventTester is placed in a level with ActorRef pointing to some other Actor in the level. During runtime, ActorRef is changed to point to a different Actor. The Actor that ActorRef used to point to is destroyed, executing RefEventTester’s OnDestroyed(ActorRef), when it should not.
Here is RefEventTester’s event graph, which exhibits the first scenario:
Finally, here is the output generated by RefEventTester doing its thing, demonstrating that OnDestroyed(ActorRef) is only triggered once:
I have also provided [a simple level][4] to demonstrate the behavior.