I know this has been answered before but I still don’t get it.
this is my code:
var enemy = hero.findNearestEnemy();
hero cleaves and then says “but it’s dead…”. Code get stuck there. only cleave doesnt attack
Welcome to the discourse
I suggest you put this statement inside the while-true loop at the very top
thank you very much. still not sure why var needs to be inside the loop
You’re welcome, because it has to refresh every time you kill the enemy. Once you kill it, enemy would be none, so if you have it in the while loop, it will always have the nearest enemy, if it is outside, it would find the nearest at the beginning of the level and ignore the rest
makes sense now, thank you!!
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.