I created the two arrays of objects, so it doesn’t loop infinitely.
The ingame situation is this:
There are circles on screen, with different colors. When I press a circle, an aura starts to grow around it, and when it reaches the other circles, it either changes their color, or destroys them, based on their color.
The change of color is done by spawning a new circle of different color, then destroying the old one.
The problem with this,was, that the new circle was in the" Aura" so it triggered an infinite loop.
I wanted to solve this, by putting the new circles in an array, and checking before each "color transformation"if the circle is in the array of new circles(New Green, New Blue), or not. If it’s not in it the spawn/destroy mechanism carries on, spawns a new circle, and puts it in the array that will be checked.
I still get the infinite loop error.
Does anybody have a good idea, on how to solve this, and why is this happening?
Thank you.
well as far as I can follow its not infinite however the engine will see any loops more than a certain amount as infinite. see
beyond that i dont have an editor availible to me at this second but is that assign function hand made or a ue4 function if its hand made i would check that.
This should loop maximum once, that’s why I put in the new objects in an array, and then check onOverlap, if they are part of the array of newly spawned objects… I don’t know what Assign function you mean, but everything in the graph is an UE4 function…
ahh I was looking at the pic of the for each loop macro and getting confused sry. I’m not actually seeing any loops in the other graph, no idea where in there an infinite loop would be, have you tried breaking the connection to the switch to make sure that is the section of code that is causing the issue’s. if so I would just keep testing it by breaking connections down and seeing when the error crops up.
Thanks Syhcris for suggesting to break down connections, now I see what causes the problem:
Whenever SpawnActor is called it jumps back to OnBeginOverlap, so it doesn’t get through the SpawnActor, and therefore doesn’t put the newly spawned objects into the Array. Do you have a good idea on how to get past this?
ahh ok is it possibly creating the actor in the overlap area and that new actor is firing the begin overlap call again on the new actor?
so it looks like your back to your original issue here
this is a tricky one if the other actor needs destroyed than do that before the spawn new actor should solve half the issue the other half is if you just need to change its color thats the tricky one but you might have to try removing the final colliding ring that triggered the rings to begin overlap, or place some other logic i there…
or adding an offset for the new spawn but that might be messy… might spawn in the middle of another, getting direction etc…
Thanks for the suggestions, I already solved solved it in a tricky way, wasn’t easy to figure this out, but at least I felt like genius while doin’ it,haha
Here’s the final working solution, in case somebody would find himself in a similar situation.