It keeps going back into the wall can anyone help?
x = hero.pos.x
y = hero.pos.y
y = y - 10
while True:
enemy = hero.findNearestEnemy()
if enemy:
# buildXY a "fence" 20 meters to enemy's left.
hero.buildXY("fence", enemy.pos.x - 20, enemy.pos.y)
pass
else:
# moveXY down 10 meters.
hero.moveXY(x, y)
pass`Preformatted text`
You can’t use variables that you’ve defined outside the while loop. They will stay as two constant values like 24 and 30. You need to use values which will change with your movements. hero.pos.x and hero.pos.y. Note that you also need to move down 10 meters, so you’ll need to subtract 10 off hero.pos.y.