Code:
function Create(self)
grav = SceneMan.GlobalAcc.Y;
Vel = 25;
function lengthdir_x(dist,ang)
return dist * math.cos(-ang);
end
function lengthdir_y(dist,ang)
return dist * math.sin(-ang);
end
Holding = 0
curdist = 100
avgx = 0
avgy = 0
dist = 0
end
function Update(self)
for actor in MovableMan.Actors do
if actor:IsDead() == false then
avgx = actor.Pos.X - self.Pos.X;
avgy = actor.Pos.Y - self.Pos.Y;
dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
if dist < curdist then
target = actor;
end
end
end
if (Vel^4 - grav * (grav * (target.Pos.X - self.Pos.X)^2 + 2 * (target.Pos.Y - self.Pos.Y)^2)) > 0 and (UInputMan:KeyHeld(8)) then
local Angle = math.atan2(Vel^2 + math.sqrt(Vel^4 - grav * (grav * (target.Pos.X - self.Pos.X)) + 2 * (target.Pos.Y - self.Pos.Y)^2) / grav * (target.Pos.X - self.Pos.X));
self:SetAimAngle(Angle);
else
print("TOO FAR AWAY");
end
end
Now it spams the Too Far away message, even when an actor is within range.
It also says that on line 28 in the math.atan2 that it expected a number, but got nothing.
By the way,
is line 28's equation.