Python I don't understand this ;(

What did I do wrong ? (Underground business)

Your pet can’t see around corners or through walls. In your function you’ve coded your pet to move to the nearest coin and then back to the hero.pos. Once the pet returns, it can’t see any other coins so it just sits there. The only way I’ve gotten this to work is to send the pet to four specific XY coordinates around the room and then return to the hero.

You need a condition for nearest to work:

if nearest:
    pet.moveXY(nearest.pos.x, nearest.pos.y)
    pet.moveXY(hero.pos.x, hero.pos.y)

edit: NVM, “if nearest” won’t work in this case because the pet doesn’t pick up any coins. It just drags them to the player. If you try to use if nearest, your pet will just be stuck at the first coin. You’re intended to do what MunkeyShynes said and have the pet move to specific coordinates to gather coins.

Thanks you for This :smiley: !