I am having a problem with the level Wild Horses and I keep getting an error that says: cannot read property 'x' of undefined.
Here is my code:
# How do you find the nearest friendly unit?
# horse = ?
horse = hero.findFriends()
x1 = horse.pos.x - 7
x2 = horse.pos.x + 7
if x1 >= 1:
# Move to the horse's y position but use x1 for the x position.
elif x2 <= 79:
# Move to the horse's y position but use x2 for the x position.
distance = hero.distanceTo(horse)
if distance <= 10:
# Move to the red x to return the horse to the farm.
# Move back out into the pasture to begin looking for the next horse.