I have a setup that feels fairly simple.
The character creates the spawner, the spawner creates the floor.
(The floor is a child of the spawner, as is a few other bits)
Done.
But for some reason, the spawner to floor relation just explodes.
Not sure if this is related to loops. But connecting up this “spawn actor floor” makes the “begin play” go through a second time? Weird.
1.not connected result
2.when connected result
However, the “spawn actor floor” does only trigger once. Shown here.
Typical . You need a condition that breaks the loop.
Create a boolean variable, initial value is FALSE
If your loop starts, test this variable.
2a: if TRUE: Stop. Don’t execute the loop. Exit the loop and set it to FALSE
2b: If FALSE: Execute the loop, set variable to TRUE
Another option is a FOR loop, run from 0 to 1, or any number you want the loop to be executed. This implies the previous code (so don’t ■■■ this)
A good example is the construction blueprint script to create a spline - examples enough on the internet.
Thats a great idea.
I need to quickly just read up on breakpoints. I’ve not used them so much, so I’ll need to do a few tutorials on how to properly use them.
Interesting.
I’m not seeing where the loop is to break?
Sorry If I’m slow to respond, I’ve got to rush out to work for the evening.
Thanks for the responses. I’ll look into both of these and get back to you.
Just right click on Begin Play and Add Breakpoint. On Play when it breaks there will be some arrows at the top; click the right arrow to go node by node.
You’ll find the loop when it start to repeat after a spawn node.
I think the best place is directly after beginPlay event, as that seems to be the location where BindEvent is referring to. Or just before BindEvent is called.
Another option is, if code is to be executed multiple times, define it as an integer, set it to the number of loops - 1, decrease the variable on each loop and break it when it reaches zero. the advise to step through the code is valid - it can show you the place where the loops needs to be broken.
OK, so I’ve played with breakpoint, which I gotta say is a wildly sick system to have. So thank you for making me aware of it. It’ll solve a lot of issues.
It seems I’ve ended up here with this, creating an infinite loop.
teh character hits player start, creates the spawner(isnt a childbp of the character), which then creates the floor etc(which are childbps of the spawner)
Yeah I threw in a bind to kill the infinite loop but I think it actually just fractionally masked the infinite and left me chasing ghosts. Ive removed the bind and Im back to infinite loops.
Yeah, I did exactly the same and was getting the same result. Mine was due to a child blueprint of the spawner.
I solved/bugfixed this by removing the bind fix and just going back to the infinite loop and really looking through on why I was getting an infinite loop.
If youve got some images or something, could probably have a look through it?