because vector isnât looking for the yak which means when you scanned for the yak there was no use for it in the second part because you did not include a code to search for yak
@Dragonlouis, the vector here should be goal. If you want you could replace every variable vector with another variable. Otherwise, keep you code as it is.
You know what to many have their own opinions because a program can be written many different ways so here just take a look at this topic maybe it can help you because Chaboi_3000 explains some things in here maybe this can help instead of confusing you.
not working, my code is. But, really, all I did was change what the variable was called, right?
goalPoint = Vector(78, 34)
while True:
# This creates a vector that will move you 10 meters toward the goalPoint
# First, create a vector from your hero to the goal point.
goal = Vector.subtract(goalPoint, hero.pos)
# Then, normalize it into a 1m distance vector
goal = Vector.normalize(goal)
# Finally, multiply the 1m vector by 10, to get a 10m long vector.
goal = Vector.multiply(goal, 10)
# To avoid the yaks, if you get within 10 meters of a yak, you should vector away from it.
yak = hero.findNearest(hero.findEnemies())
distance = hero.distanceTo(yak)
if distance < 10:
# First, make a Vector from the yak to you
yak_vector = Vector.subtract(yak.pos, hero.pos)
# Now use Vector.normalize and Vector.multiply to make it 10m long
yak_vector = Vector.normalize(yak_vector)
# Once you have the 10m vector away from the yak, use Vector.add to add it to your goal vector!
yak_vector = Vector.multiply(yak_vector, 10)
goal = Vector.add(yak_vector, goal)
# Finally, determine where to move by adding your goal vector to your current position.
moveToPos = Vector.add(hero.pos, yak_vector)
hero.move(moveToPos)