As you see:
Anter is following me, but i casts invisbility
I guess he is chasing your targetPos. I coiuld be mistaking though.
you can predict the position of the hero if they get your veloctiy
Well, i wanna know how
Velocity is practically speed and direction, so you got to do distance measurements and time calculations, maybe use vectors and u will get it.
How to write the code?
how to use velocity?
Im honestly not so sure how its possible with code, but physics wise, speed is distance over time and the velocity is knowing the speed and the direction, it is a vector
If you go
hero.move(eh.velocity)
you just move like (17, 16)
well no, you need to use what you know about the velocity and with that you can assume where the position might be
so you see, oh s/he moved from this point to this point in this time, so it will probably go the same distance in the same direction, so in this time, it will be there
in that sense
Well, how to write that
Hello everyone, I tried by my self but still can’t chase invisible enemy:
while True:
eh = hero.findNearest([e for e in hero.findEnemies() if e.id == "Hero Placeholder 1"])
if eh:
v = eh.velocity
x = v.x
y = v.y
nexX = 0
newY = 0
newPos = Vector(0, 0)
# if x == 0 and y == 0:
# while hero.distanceTo(eh) > 3:
# hero.move(eh.pos)
# hero.buildXY('bear-trap', eh.pos.x, eh.pos.y)
# else:
if x > eh.pos.x:
newX = x - eh.pos.x
elif x < eh.pos.x:
newX = eh.pos.x - x
if y > eh.pos.y:
newY = y - eh.pos.y
elif y < eh.pos.y:
newY = eh.pos.y - y
newPos = Vector(newX, newY)
hero.move(newPos)