How ever when I hit run my guy would go through the attacks while running up to the top of screen to kill the enemies and at very end just stop until the time ran out and I would fail.
So I rewrote the code in a much longer way and it works every time, however my character just doesn’t run to the top of the screen anymore.
I don’t think so but it might be the language your using. I used python and it worked for me if
I do:
Find Nearest Enemies
distance to:
if enemy distance < 10:
if enemy:
if self is ready (cleave):
cleave enemy
move to original position
else:
attack enemy
move to original position
Well that explains why your 2nd solution works then. Your 1st solution didnt do what you needed to do. Does it make sense on why your 2nd solution works?
and now it works, I didn’t change anything. How is it false?
If the enemy walks within a distance less then 5 units then I will cleave the enemy if it is off of the cool down. Else I will just attack the enemies with basic attacks. I don’t understand what you are saying. Doesn’t the code work like this?
if this is true, which is it when the enemy comes with in 5 units of my character and I have cleave off cool down then it will run that code.
else it would be false for one of 2 reasons, either the unit isn’t within 5 units of me or cleave is on cool down. Which makes the statement false because both need to be true for the statement to be true so it will run this code
} else {
hero.attack(target);
}
which will make my character to basic attack all enemies while waiting for cleave to come back off cool down resulting in the cleave to happen again.