I supose that blender don’t acuealy crash, but it hangs up on the logic tic when the while loop where runned for the first time,
The engine works in the way that it need every script/action to finich in order to advance to the next logic tic, when u set an infinity while loop the script never finich and therfor the engine never goes to the next logic tick and then “frezes”
I might be wrong, but I think this is why it chrashes 4 U
(sry 4 bad spelling, had no spellchek on this computer)
I think you might be misunderstanding how while loops work. While loops are like for loops, but they go on until the condition is satisfied. If distance is greater than 1 when the game starts, then it will continually execute cont.activate(anim_walk) in the current game frame, and so never continue to run the game. Why would you want to replace the if statement with a while statement? Why not just run the script every frame, if you want that?
better avoid to use while because can due this, just you can forget to write one line.
if you have a “undefinied” loop you can also using the normal for , with a big number.
at least in the worse case you make just some useless calculation
L=[]
x=0
while x<10:
L.append(x)
x+=1 # if you forget this line the game freeze
print(L)
L=[]
x=0
for i in range(100000) :
L.append(x)
x+=1
if x > 10 :
break
print(L)
just to know, but in this case “if” make the right work as say SolarLune