Blueprint Array Remove Index/Item and Event Tick interaction bug
Using 4.10.2, I've discovered that the blueprint nodes "Remove Item" and "Remove Index" for arrays of actors do not appear to function correctly when the array itself is iterated over in a event tick.
If you have an array of actors that are accessed and processed during an event tick, and then remove and destroy one actor in the array, you will receive errors in the PIE log after exiting, telling you the actor is still in the array and pending kill. If the array is not iterated over in the event tick, things seem to work normally.
I created a sample project with this bug: when the 2D example map is open and played, the player character creates a bunch of ledge actors which get added to an array that is iterated over in Event Tick. Pressing Q removes and destroys one actor, then closing the PIE will bring the errors in the logs to the fore. If the iteration in the Event Tick is removed, and instead pressing R is used to remove an actor, there is no problem.
I understand that this might be my error, and that in fact the Remove Item and Remove Index nodes do not remove the item or index immediately - however, I've not seen any documentation about this. Either way, bug or not, does anyone have any suggestions as to how to remove the actor from the array while still iterating? Or would the simplest solution be to halt the the processing in event tick for some amount of time (0.1 secs?) and resume once the actor has been removed and destroyed?
All help appreciated, and if this is a bug and more detail is needed, please ask!
After testing this, all you need to add is an IsValid check before triggering the Custom Event in the platform blueprint. Since one of the platforms is destroyed and no longer valid, it causes errors if you attempt to activate the event.
Let me know if that works for you or not.
answered Jan 28 '16 at 07:18 PM
TJ V ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here