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