Error: Find distance to target unity - Siege of Stonehold (JS)


#1

Error: Find distance to target unity

if (this.distanceTo(enemy) < 10) {

Why is this an error.
This has’nt been an error before, but on this level it is


#2

There probably isn’t an enemy within sight at some point; have you checked whether the enemy exists first?


#3

@nick No, how do i do that?


#4

To check if an enemy exists, you have to have the line of code

if (enemy) {

because an enemy has to be there for that line to work.