Okay so getting straight to the point:
I got a simple blueprint that spawns a room and when the room spawns, it will set 6 different ChildActor classes randomly from the game instance’s array using ForEachLoop.
And it actually works, no questions asked.
When ForEachLoop completes, the blueprint casts the existing door that is in the room to check if it’s locked, if it is, it will pick a random lootable out of the 6 (which is either drawer or bookshelf) to spawn a key in as seen here:
Most of the times it normally works, it checks for the door and if it is locked it spawns the key.
Problem is that even though if it picks a random lootable out of the array which EXISTS in the world, it will sometimes fail and the key doesn’t spawn even though the cast node to door detected if the door is locked, which means that the player is stuck in the room unable to go proceed any further. This can be seen here:
It CHOOSES and DETECTS the actor but still manages to fail the cast? I don’t think that is how it’s supposed to work.
Even adding delay after ForEachLoop completes doesn’t fix the annoying issue. I also tried like my 3 other methods and yet no luck towards fixing it and I am left grey in this situation.