Archer Strats for melee

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

1 Like

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 :slight_smile: tell me if u need more help

2 Likes

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.)

1 Like

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

1 Like

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?

1 Like

yea, if you don’t understand why this works, I can explain. Please dont use it without knowing why it works tho :stuck_out_tongue:

Yeah, I didn’t really understand vectors yet

1 Like

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

1 Like

yup, your catching on rlly fast!

2 Likes

Thx bro, it helps :slight_smile: (20 chars lol)

1 Like

There’s a bug when I put the code in my loop:
image
(It says “target an x and y value”)
I also have programmation V, so vectors aren’t the problem

1 Like

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

x.pos.pos,y.pos.pos

1 Like

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

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

1 Like