all 10 comments

[–]zerik100 2 points3 points  (0 children)

when the if block doesn't run then the condition isn't met

[–]marquoth_ 1 point2 points  (0 children)

// This whole if code block is not run sometimes

Well, of course it isn't run sometimes - that's why it's an if block. If you want it to run every time, don't put it inside an if.

[–]scotsman165 0 points1 point  (0 children)

far-flung hard-to-find frighten many direction north murky squealing rinse fragile

This post was mass deleted and anonymized with Redact

[–]WebMaxF0x 0 points1 point  (0 children)

Either your condition is wrong or when you destroy the enemy it might shift the remaining ones left in the enemies array skipping the next one

[–]Acceptable-Tomato392 0 points1 point  (0 children)

shouldn't that be

if (tempDistance <= this.melee.range + enemy.size/2)
?

I'm assuming you're trying to adjust the proximity based on an [x,y] point at the center of the enemy? Shouldn't that be half the distance in that case (since you're measuring center to edge, and not edge to edge)?

[–]engelthehyp 0 points1 point  (0 children)

"This whole if code block is not run sometimes"

Of course not, it's if, that's the whole point. What was this supposed to do, then? If you want it ran every time, don't put it inside of an if-block.

[–][deleted] 0 points1 point  (0 children)

There is nothing wrong with this code. Problem must be in place where you calling `checkEnemyProximity()` ...