Download

Is there an event that gets triggered every time an actor of any class gets spawned?

Is there an event that gets triggered every time an actor of any class gets spawned? I’d like to implement some custom logic for everytime an actor spawns and I don’t know if there is an event or another way to do it. Thanks in advance for any reply!

virtual void BeginPlay();

Though there are a bunch of different events depend on when in the process you want to tap in.

UWorld::AddOnActorSpawnedHandler( const FOnActorSpawned::FDelegate& InHandler );

Thank you so much! This is exactly what I was looking for!
Just in case, is there a similar function for when whatever actor gets destroyed? Because I couldn’t find it.
And is it possible to revert the destruction of an actor?
Thanks again!

Also for editor you can use FEditorDelegates::OnNewActorsDropped

Each actor has it’s own delegate for when it’s destroyed. I don’t think there’s a global one. And no you cannot undo the destruction of an actor at runtime.