Target range coordenate
Posted: Sun Feb 19, 2023 12:36 am
have any wayt to get coordenate of distance of the target selected?
Like this example, i'm need follow target in range 100
Code: Select all
function FollowDistance(target,dist)
YQ = target:GetLocation().Y
YP = self:GetLocation().Y
XQ = target:GetLocation().X
XP = self:GetLocation().X
Mp = -1/((YQ-YP)/(XQ-XP))
if ((-2*XP-2*Mp*Mp*XP)*(-2*XP-2*Mp*Mp*XP) -4*(Mp*Mp+1)*(Mp*Mp*XP*XP + XP*XP-dist*dist) > 0) then
undersqrt = (-2*XP-2*Mp*Mp*XP)*(-2*XP-2*Mp*Mp*XP) -4*(Mp*Mp+1)*(Mp*Mp*XP*XP + XP*XP-dist*dist);
else
undersqrt = (-2*XP-2*Mp*Mp*XP)*(-2*XP-2*Mp*Mp*XP) -4*(Mp*Mp+1)*(Mp*Mp*XP*XP + XP*XP+dist*dist);
end;
XN = (-1*(-2*XP-2*Mp*Mp*XP)+math.sqrt(undersqrt))/(2*(Mp*Mp+1));
YN = YP + Mp*(XN-XP)
MoveToNoWait(XN,YN,self:GetLocation().Z);
end;
repeat
if (Target() ~= nil) then
FollowDistance(Target(),100);
end;
break;
until false;