I feel like this is straight forward, but I cannot run delayed code through an actor that is destroyed in the same impulse, so I thought another actor could just trigger it however I can’t get this to return true when myplayer is destroyed.
I think you are misunderstanding what you’re doing when you’re binding an event. You cannot bind the “On Destroyed” callback within the very same event you want to bind it to.
When you bind an event, you’re just letting the compiler know that when the actor you pass in (the Target) is destroyed , you then want the event you’re binding to be called. So you need to do your binding somewhere like in Begin Play, so it’s setup and ready to go for when the actor is destroyed.
You also will need to find a way to get a reference to the other actor. Maybe I’m missing some context here, but if this code is running in a separate actor from the one being destroyed, your cast will always fail, because this actor doesn’t know anything about the other actor. You could use a “Get All Actors of Class” to get a reference that way… a much better way would be to create a new variable that holds an Actor object reference, expose it, and then assign the actor you want in the editor.
Thankyou, I was able to find some resources referencing how to bind custom events, I originally was doing this using custom events but I ran into issues appreciate the help.
My recommendation would be to put the logic for what happens when you destroy an actor either in the game mode or execute the logic before you actually destroy the actor.
Since you are changing the level, I would place that in the game mode and before the actor is destroyed, call the logic in the game mode then destroy the actor.