Every now and then my blueprint refuses to compile(it breaks it) "For each loop"

Hello ,
I am facing this problem

When i create something that has a for each loop my blueprint compiles and runs perfectly fine but after a while everything falls apart and the system breaks all dependencies.

If i delete one of them and re do it it will stop giving me errors but only for a short time.
What is going on??

EDIT: It appears that it does this only if a have an exec node connected to them.If i delete them then my BP compiles just fine.Is this normal behaviour?
EDIT 2: It now refuses to compile again and it gives me the same errors but without the visual warnings!

Hi ,

Can you give me a little more context to what is triggering the execution? Also, I have noticed that in your image, you have a for loop that contains a Delay node. It will create errors as Delay is a latent function that happens over time, while a For Loop tries to trigger instantly.

How are you creating the For Each Loops? Are you dragging from an output array and then making one from that context? Are you trying to creating a For Each Loop that is not of any type, then connecting an array? Any additional information may help with the investigation.

Thanks!

Hello ,
The delay node was left there for one of my experiments and i had the same problems without it as well.
For some reason if you have a ‘get all actors of class’ node ,you choose an actor, and then drag from the array a ‘for each loop’ it works as intended.If for any reason you decide to change the actor inside the node then it breaks compatibility with the for loop and you have to delete it and drag out a new one for it to work again.Is this normal behavior ?

What is even weirder is the fact that when i finaly gave up and returned to my game in the morning,when i reopened unreal everything was fine and this : Do Arrays work correctly? - Programming & Scripting - Epic Developer Community Forums now works correctly!!
It counts all of my actors as it should.I have to assume that it was a system glitch and closing and reopening my project fixed it.I am sad that i wasted a day of my life with this extremely weird situation but at least i am happy that it now works.There is definitely something wrong in there but i cannot pinpoint the origin of the problem.

Hi ,

So what is happening there is the For Each Loop is context sensitive to the input array. So when you changed the Get All Actors of Class that was feeding into that loop, it got confused. The For Each Loop can only take an array of a specific variable type with instantiated. Each time you switch the class, the loop has to be replaced.

When you close and reopen your project, it clears out that data and replaces it with a new instance which fixes the compatibility error with the variable and loop. Let me know if that helps you or if you have any other questions about it.

Cheers!