Page 1 of 1
moving a set distance
Posted: Wed Feb 12, 2014 8:13 am
by ZZZZZ
Say you have a waypoint at point A, and your character is standing at point B, how would you go about moving 200 distance
towards A from B? I figured you can use 'local playerX, playerY, playerZ = player.X, player.Y, player.Z' to get the current position but i'm not sure how to go about moving 200 distance towards A from that location. Any help would be great

Re: moving a set distance
Posted: Wed Feb 12, 2014 9:35 am
by rock5
Well there is a function player:moveInRange(target,range,ignoreCycleTargets) but it works with range to target not range from start. But you could get the distance to the target and then minus 200 from it to give you the range to target. Eg.
Code: Select all
dist = distance(targetWP,player)
range = dist - 200
player:moveInRange(targetWP, range, true)
Re: moving a set distance
Posted: Wed Feb 12, 2014 4:10 pm
by Administrator
You can use some simple trigonometry to get a point based on distance and angle.
Code: Select all
local tx, ty;
local angle = math.ytan2(B.y - A.y, B.x - A.x);
local dist = 200;
tx = math.sin(angle)*dist;
ty = math.cos(angle)*dist;
Re: moving a set distance
Posted: Wed Feb 12, 2014 8:40 pm
by rock5
I was trying to avoid that. Doing those annoys me. So i used a function that already does it. I guess both solutions should be similar.