(Hunter triplets) "Find the distance to a target unit" error

Hi! I’m trying to define distance to the nearest enemy, and I think it should work even if there are no enemies, but I’m getting an error:
"Line 5, time 0.0: Find the distance to a target unit."
My code:

enemy = self.getNearestEnemy()
if not enemy:
    return
dist =  self.distanceTo(enemy)

Level: Hunter Triplets
Language: Python
OS: Windows 8.1
Google Chrome

I see this bug with Python; it’s a problem in our API protection, I think.

Try this:

dist = self.distanceTo(enemy.pos)

Edit: this is fixed now.

1 Like

enemy.pos is working, thanks!

I’m currently running into this issue while playing http://codecombat.com/play/level/dueling-grounds?team=ogres.

Tried

distance = self.distanceTo(enemy)
# and
distance = self.distanceTo(enemy.pos)

I’ve had no issues with distance until now.

edit: Also happening on /level/multiplayer-treasure-grove.
edit: Seems to happen on every level now.

And you’re sure that the enemy exists, i.e., it’s not dead?