Object not triggering events from reference

Hi

I’m using Objects to run certain functions. As I understand it, Objects can be used to run functions and events, and will get garbage collected when nothing is referencing it. So keeping its reference alive for as long as I need it, and then removing the reference to delete it.

I have made a Parent Object that implements the Interface and can have some events and variables avaliable to all children, I store all the children under it’s parent reference. That way I can store all Objects in an array and trigger the shutdown interface / event from the reference in the array.

When constructing the object, I call the Initialize function, this works fine and prints.
And before removing the reference, I call the Shutdown event from the stored reference.
However, the Shutdown event is never triggered on the children Objects.
If I print from the parent, it will print. But the children never prints.

image

Any idea why this might be happening? What am I missing here?

Thanks :slight_smile:

And before removing the reference, I call the Shutdown event from the stored reference.

Can you show calling the shutdown? Can we see it?

This is the function ( on the Player Pawn ) that gets the reference, calls the Shutdown Interface event and then removes it from the array.

My bet is that whatever you pull out of the Map is not valid. Put print string there, see what you get.

Also, where did you read about dereferenced object being destroyed?

2 Likes

Thanks, i found the issue. The reference was indeed referecing the wrong object, an error in a different location of the code that changes the reference. I forgot about it, and thus expected that Blueprint’s functions to be triggered, when it was triggered another blueprint’s functions lol…

Thank you!

2 Likes