Hi, I have an array of stored actors and at one point destroy some of them by using ‘destroy actor’ on the item in the array. My array still keeps the same names of the instances after this. I’m guessing a ‘destroy actor’ will destroy the instance but not touch the array and I will have to do something else. Is there anything else I can do but also removing the item from the actor array? I’ll have to do a few things extra for this but want to know if I really have to physically kill the actor and also its reference in the array.
Is there anything I can do to make the array have a ‘live’ connection to the actor?
I have this quite a while ago, and it was a bug but on a function’s local variable.
So can you also try this? when ever you try to access your array element, put a isValid node before you use it.
Make sure you connect both valid and not valid pin to something else. If your graph is anything like what I posted in above link, also connect the branch False pin to something else
If not, then it’s probably a good time to report that.
Also, on the topic of automatic dereferencing for everything.
It is certainly hard if you can only destory actor from blueprint where the array does not reside.
However, this could be a work around if you keep a bool variable in actor you want to destroy as bDestroyed.
Then check the reference if it’s destroyed, set the variable/array index to None.
I do not know if this will work or not as I don’t know how a actor destroyed, do they clear everything and just keep empty shell and name, or the object is still intact until all the reference are properly dropped.
“destroy actor” definitely removes the actor instantly as a visible actor of the game and it looks like it is (somewhere) flagged for the next garbage collection cycle to remove it from memory.
I looped through an array of 20 actors 2 times. First time calling only “destroy actor”, second time to clear up the array. Within the second loop the first 5 to 9 elements still held references to the actors. I guess that was for the time between two garbage collection cycles.
Maybe they did fix the bug in form of garbage collection I guess. The answerhub bug I encountered is persistent, I can wait for a long time and trigger that function it still have the referenced object and name.
I guess for RumbleMonk to have more instant feedback(maybe he used that for inventory), I would suggest doing the destroy from the blueprint keep the bp.
loop array->send event/interface call to destory actor->set array element to None. This should prevent weird behavior.