Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Unreal's long standing array bug

Author: Mike McGoveran
Date: 6/16/2023

The Problem:
I have read a few times in other research about a bug in Unreal's blueprints with generating arrays, but had yet to experience any issues myself.  This week that had changed.  Here is the scenario:  During run time I have an event that fires and needs to retrieve a list of all our AI pawns currently inside a room.  Then I need to iterate through that list and run some logic on each one.  Sounds like a simple task.   First I should add a box collider on the room.  Then I should run a GetOverlappingActors node to get the array when triggered.  Then send that array output node into a for loop that runs the logic.

The solution should look like this:


The above instead provided inconsistent results.  I had 16 AI in the room when this would attempt to fire and kill off all the AI.  Sometimes I would kill all but 5,  other times it would be all but three.  The interesting thing I noticed was that a specific AI in the list would almost never die.  It didn't matter what type of AI or what the delay was between spawning them and killing them.  This initially lead me down a rabbit hole of troubleshooting collisions as the logic in the picture should have just worked.  At the end of a few hours of troubleshooting (which wasn't easy with the current protests shutting down the Unreal Subreddit) I was at a loss, until I remembered others mentioning issues with arrays on other research tasks I had been on.


The Real Solution:
The  solution to this issue, which sounds silly when we think about the way blueprints translate into code on the back end,  is as simple as saving the array as a local variable before we send it into any other logic.

Like so:


Since this change, I have yet to see this event miss a single AI in it's sweep of my room.  My research shows that this perplexing bug has existed since 2016.   One of the many issues I am finding with this engine as I develop in it, and one that could be detrimental to a project as it grows.
Hope this post helps someone else further down the road.

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.