@mikesympath (Mike Smith) posted a new topic, subject "(Hunter triplets) "Find the distance to a target unit" error". It read:

   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:
    [code] 
        enemy = self.getNearestEnemy()
        if not enemy:
            return
        dist =  self.distanceTo(enemy)
        
    [/code]
    
    Level: Hunter Triplets  
    Language: Python  
    OS: Windows 8.1  
    Google Chrome

@nick (Nick Winter) replied

    I see this bug with Python; it's a problem in our API protection, I think.
    
    Try this:
    [code] 
        dist = self.distanceTo(enemy.pos)
        
    [/code]
    
    **Edit** : _this is fixed now._

@mikesympath (Mike Smith) replied

    enemy.pos is working, thanks!

To which @dideler (Dennis) replied

    I'm currently running into this issue while playing http://codecombat.com/play/level/dueling-grounds?team=ogres.
    
    Tried
    [code] 
        distance = self.distanceTo(enemy)
        # and
        distance = self.distanceTo(enemy.pos)
        
    [/code]
    
    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.

Then @nick (Nick Winter) said

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


{'source': 'discourse', 'url': 'https://discourse.codecombat.com/t/hunter-triplets-find-the-distance-to-a-target-unit-error/1300', 'title': '(Hunter triplets) "Find the distance to a target unit" error', 'views': 2444, 'has_accepted_answer': False, 'word_count': 168, 'like_count': 1, 'reply_count': 1, 'participant_count': 3, 'posts': 5, 'tags': '', 'author': '@mikesympath (Mike Smith)', 'participants': '@mikesympath (Mike Smith), @nick (Nick Winter), @dideler (Dennis)', 'image_url': [None], 'created_at': '2014-11-09T12:57:11.394Z', 'last_posted_at': '2014-12-18T16:58:55.892Z'}