In my project, I’m trying to use an Event Dispatcher to trigger a custom event when an object is destroyed, but my custom event isn’t working as expected.
Here’s the setup:
First Screenshot (Level Blueprint)**: I have a For Loop that spawns an object, binds an event to the On Target Destroyed dispatcher, and associates it with my custom event TargetDestroy. When the dispatcher is called, it should trigger TargetDestroy, which then prints a “Hello” message as a test.
Second Screenshot (Other Blueprint)**: In the other blueprint (for the object being spawned), I have an Event Destroyed node, which calls the On Target Destroyed dispatcher. This is intended to notify the Level Blueprint that the object has been destroyed and should trigger the bound TargetDestroy event.
However, despite this setup, the TargetDestroy event in the Level Blueprint doesn’t execute as expected. I’m not seeing the “Hello” message, which suggests that the custom event isn’t being triggered.
When are you destroying the Cible ? you might be destroying it right after spawn which doesn’t give the event dispatcher time to bind. Also just to be sure try adding a print after the bind node.
I destroy my cible when a projectile hits it in my “bp_projectile” .
I tested prints everywhere, especially after the bind or after the “Event Destroy” and they are displayed but the only print that is not displayed is the one located after my cutom event
Can you add a breakpoint (select node and press F9) to the Cible DestroyActor in your last image, and another breakpoint to the bind node and play and see which one triggers first.
yes but however my “print string” works well when it is placed behind the bind or anywhere after the “destroy actor” so how it’s possible ? Now it works, I don’t understand why the other nodes work but not the event?
Edit : if i try to call my event while the actor no longer exist, it will not be called but the other node is execute because this is the continuation of the instruction ?
But thank you I didn’t know it worked like that I’m new to ue5