Does anyone know how to make archers move back and surround a melee unit when they come close?

Hmmâ€¦ I think youâ€™d have to use maths and modulo / a `for`

loop

try using the code from the Skating Away level. The vectors there are used to make the code tell me if u need more help

for loop wouldnâ€™t do anything, but I have an idea of how to do it with math

That level isnâ€™t very useful for this, maybe brew ball would be

bro the vectors help alot bro

I need some more help on vectors. Why should you normalize a vector and multiply it by 10? (I made the mistake of copying someoneâ€™s code so didnâ€™t learn the concept.)

here,

if enemy:

```
goalPoint = friend.pos
goal = Vector.subtract(goalPoint, enemy.pos)
goal = Vector.normalize(goal)
goal = Vector.multiply(goal, 2)
distance = friend.distanceTo(enemy)
yV = Vector.subtract(friend.pos, enemy.pos)
yV = Vector.normalize(yV)
yV = Vector.multiply(yV, 2)
goal = Vector.add(yV, goal)
```

thats the vectors u need to use

you dont want to do that, you only want to multiply it by 2 or not even multiply it

Should you command that friend to move goal?

yea, if you donâ€™t understand why this works, I can explain. Please dont use it without knowing why it works tho

Yeah, I didnâ€™t really understand vectors yet

Heres why it works, the code above calculates the distance between the enemy hero and the archer (basic distanceTo)

this part:

```
goal = Vector.subtract(goalPoint, enemy.pos)
goal = Vector.normalize(goal)
goal = Vector.multiply(goal, 2)
distance = friend.distanceTo(enemy)
yV = Vector.subtract(friend.pos, enemy.pos)
yV = Vector.normalize(yV)
yV = Vector.multiply(yV, 2)
goal = Vector.add(yV, goal)
```

calculates the best position for the archer to move to.

Oh, so the vector is the value/point when subtracted from an value

yup, your catching on rlly fast!

Thx bro, it helps (20 chars lol)

Thereâ€™s a bug when I put the code in my loop:

(It says â€śtarget an x and y valueâ€ť)

I also have programmation V, so vectors arenâ€™t the problem

dont do goal.pos, a vector is already a pos, so ur techincally doing

x.pos.pos,y.pos.pos

also instead of if goal, do if distance<=#whateverNumber

Oh yeah, because I think it would go *to* the enemy, not away