The ball keeps on hitting the red skeletons instead of the blue ones, please help me.
My code:
# Push the ball to knock over all the blue skeletons without hitting any red ones.
# The blue skeletons can be found as enemies.
while True:
ball = hero.findNearest(hero.findByType("ball"))
ballPos = ball.pos
enemy = hero.findNearestEnemy()
friends = hero.findFriends()
friend = hero.findNearest(friends)
Vector = enemy.pos
distance = Vector.subtract(Vector, ballPos)
pos = Vector.add(distance, 5)
hero.command(friend, "move", pos)
hero.command(friend, "move", ballPos)
# Push the ball to knock over all the blue skeletons without hitting any red ones.
# The blue skeletons can be found as enemies.
# The blue skeletons can be found as enemies.
while True:
ball = hero.findNearest(hero.findByType("ball"))
center = ball.pos
enemy = hero.findNearestEnemy()
friends = hero.findFriends()
friend = hero.findNearest(friends)
vector = enemy.pos
distance = Vector.subtract(vector, center)
pos = Vector.add(distance, 5)
hero.command(friend, 'move', vector)
hero.wait(1)
hero.command(friend, 'move', center)
hero.wait(1)
hero.command(friend, 'move', vector)