 # [SOLVED] Skating Away - e.copy is not a function

Hello,

I’m having some trouble with my code. When I run the current code, it’s returning an error message of “e.copy is not a function”. Here is my code.

``````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
yakVector = Vector.subtract(yak, hero.pos)
# Now use Vector.normalize and Vector.multiply to make it 10m long
yakVector = Vector.normalize(yakVector)
yakVector = Vector.multiply(yakVector, 10)
# Once you have the 10m vector away from the yak, use Vector.add to add it to your goal vector!
pass

hero.move(moveToPos)
``````

Equipment is:
Boots of leaping
Sword of the templar
Emperor’s gloves
Gilt wristwatch
Leather belt
Proggramaticon V
Ring of speed
Twilight glasses
Sapphire sense stone
The Precious
Basic Flags
Boss Star III
Enameled Dragonplate armour
Deflector
Wolf

Thanks!

At a quick glance, I noticed that you are missing the pos for the yak in this line.

``````yakVector = Vector.subtract(yak, hero.pos)
``````

Also, remember that Vector.subtract is very particular about which point comes first. Look at the one above to see “from vectorA to vectorB” in the comments and then how it is set up in the code.

1 Like

Ah, thanks. Don’t know how I missed that.