Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

My soldiers stay still and don't attack, why?


I have used this piece of code in another level and everything worked just fine, but now in Hunting Party level I am using this and my soldiers walk but when they reach their destination they just stand still, what’s happening?

for friend in self.findFriends():
if friend:
enemy = friend.findNearestEnemy()
if enemy:
self.command(friend, “attack”, enemy)
self.command(friend, “move”, {“x”:friend.pos.x+20,“y”:friend.pos.y})


For someone who has been a member of this community for over a month, one would think you would have learned to format your code by now. Please learn how to. We can’t be here for you every single minute.

Is this code in a while True: loop or in a regular loop? If it isn’t it would only run once, which could explain your problem.


Please tell me where that formatting information is so I can see


If you go to thd list icon at the top right pf the website and click it, there’s a link that says FAQ. Read it.