WhileLoop and Infinite Loop

Hi guys! Whats wrong with my SpeedDuration?

I think that the while loop never completes, so you never toggle the running boolean.

It just goes into the while loop and decrements the duration value and sets it forever.

Why are you doing a while loop there?

The while loop will only complete when Running is set to false, which will only happen if the Run action key is pressed whenever Speed Duration equals zero. But once the key is released, it’s instantly set back to true and your loop runs again when it probably shouldn’t.

Going off the Max Walk Speed values you’re setting, it actually looks like you’re setting your booleans backwards. You would want to set Running to true when the key is pressed and false when released. Then, from that Branch’s True pin you’d want to wire that down to the same Set nodes connected your action key’s Released pin so that your character will stop running if the duration reaches zero.

I’d also use a less than or equal or a nearly equal comparison rather than exactly equal, but I could just be overly paranoid about float accuracy.

You are executing a new conditionally infinite loop every tick.

You should almost never use loops in game code. The main loop handles most looping needs. The exceptions are latent actions and arrays.

I am assuming you want to sprint for a maximum time(5 seconds). Wait some period of time(25-30 seconds) then be able to sprint again.
The following image shows exactly that.

The delay is a latent action that resets to walk mode.

You can add another branch between pressed and the waiting branch to permit multiple sprint-release-sprints in the same 5 seconds:

 if colldowntimer >= 25  
 true sets maxwalkspeed to 1200 -  no further connection 
 false connects to the waiting branch

I’m using loops to procedurally generate my world. Is this bad?

no as long as they are used correctly its not an issue, and loops are how you do procedural generation. your question is off topic though and should have been posted as its own question on the answerhub.

sorry, just kinda new and you got me worried a bit. I now understand the context. the guy above is overcomplicating things with his while loop

in my opinion the original poster didnt know how to use a while loop. all loop nodes execute between frames so using a while loop in the context given could lead to a infinite loop type situation. doing it on tick just makes things even worse in this case.