hi , so i was following a tutorial on a dungeon generator https://www.youtube.com/watch?v=4ddbnQIuwAM (great tutorial by the way) , everything worked just fine until i started the last part with failsafe , it then found an infinite loop , i couldnt figure out where it was so i deleted the failsafe part , but now it finds loops EVERYWHERE , even sends me to some macros inputs…
I m going crazy trying to find a solution , tried adding random tick delays in different parts of the blueprinth , didnt work anywhere , and starts to send me errors telling me that the delays are creating loops or something like that… Maybe i’m missing something? sorry for being incoherent , but i’m going mad trying to find a solution…
An infinite loop doesn’t have to be a For loop or a while loop, it might happen if you just do this:
Personally i would add a break point, and see what is happening, try it!
I have two guessess: your rooms are generating infinatly or your added rooms being proccessed over and over.
Also, orginize nodes, it’s hard to read
even the break points doesnt work… it just ignore them when i start the game , the blueprint hs did work initially , so i guess it’s more of an engine bug…
thanks
You should be able to check the callstack in the error message to see the loop that’s happening
Solution: Use a while loop in the Event Graph.
That tutorial shows a lot of bad practices. Best suggestion would be to split code into separate functions, and use a while-loop instead of the loop he introduces.
Thanks for posting this, it helped me realize that I was not the only one. I both like and dislike this tutorial. It showed me a new way about thinking of PCG using collisions in an intuitive way, but introduces many bad practices. Especially when he does something and states “I don’t know why, I just did it like this and it worked.”
I’d suggest breaking the whole algorithm into logical functions.
For myself, I have the following:
- Event Graph: Sets the seed, spawns the first room, starts the timer, then USING A WHILE LOOP, spawns new rooms until the room count has been reached
My functions look like this: - Event Graph → Spawn New Room → Check For Overlap (& Get Overlapping Rooms)
Event Graph
Spawn New Room
Check For Overlap
Get Overlapping Rooms
I now go from 58 rooms generated (until infinite loop) to 1000+ with no infinite loop