Infinite loop in my jumping blueprint

Hi All,

Complete Unreal noob here.

I’m trying to create a custom jumping blueprint for my player controlled pawn.

Essentially I want the player to be able to jump every 0.2 seconds and only after the player has made contact with the ground after the preceding jump. (I use my own isAirbourne function to detect this via a MultiSphereTraceByChannel)

My current (infinite loop) blueprint is:

… And I can’t determine why this would be an infinite loop?

In my head the code would be roughly equivalent to:

condition = true
while(condition) {
    if (!isAirbourne) {
        condition = false

This seems valid to me. Why does unreal treat this as an infinite loop after a very brief period of time?

Also is there a better way to achieve what I’m trying to do?

Hi there,
The reason for the infinite loop is that node While Loop node, which requires caution. And you may not need it.

I believe you want to enable the next jump after the event “on landed” resets the condition is Airbourne to false.

I am not familiar with C++, but you have an idea:

Delay doesn’t work as expected in a loop body, the loop will continue to run and will not wait for the delay to execute the next loop.

Check if they are airborne, if not, then connect a Do Once node that causes the Jump to begin, then set a 0.2 second delay, and wire that back to the Reset pin on the Do Once.

so, Branch if !Airborne, Do Once => Jump => Delay 0.2 => Reset Do Once

… also, never do while(true) in a (mostly) single threaded program!!! heh