knowing when an actor is destroyed

hi

is there a way to know when an actor is destroyed (or is this something one has to manually monitor) so that children actors associated with it can also be destroyed when they are no longer relevant / used (because their associated parent actor is dead), particularly in the case of pcg, and not directly and implicitly creating / logging the child actors in the parent

is there perhaps an event like the inverse of begin play

thanks

Hey @barbrian0723!

End Play would be triggered when you destroy an actor :blush: Not sure how you’d implement it to work in your case with PCG though.

Anyways, hope this helps :innocent:

1 Like

at this stage i let the “child” actors created by pcg (pcg actually attach these actors to the actor containing / housing the pcg component) test on begin play whether their parent (because pcg attach them) is valid, and have them destroy themselves if their parent is not valid

this is basically cleaning up pcg child actors no longer valid at begin play

it is perhaps not the entirely best approach

but so far it does the thing

will see if i can clean up with end play (when end play triggers)

it is not too difficult to determine who is a child and who is a parent

do you know whether end play is triggered only during runtime or outside of runtime as well

if you delete an actor and set the end play event, will it trigger when you delete the actor before runtime as well

Event End Play is called when actor is removed from the level for any reason. It has enum pin so you can do a switch on it to see what they are.

Event Destroyed is called when Destroy Actor is called.

I don’t think any of these two will work with PCG. I have marginal experience with PCG but I think your current approach is sound. If I discover something, I will let you know.

1 Like

many thanks