Pixels don't have deep check.
Code:
function Create(self)
-- Find Actor
for actor in MovableMan.Actors do
local avgx = actor.Pos.X - self.Pos.X;
local avgy = actor.Pos.Y - self.Pos.Y;
local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
if dist < 50 then
self.user = actor
end
end
self.aim = ToActor(self.user):GetAimAngle(true);
end
function Update(self)
local hit = Vector(0,0);
local miss = Vector(0,0);
local terra = SceneMan:CastObstacleRay(self.Pos, (Vector(1,0):SetMagnitude(50)):RadRotate(self.aim), hit, miss, self.user.ID, -1, 0);
if terra >= 0 then
local gbx = hit.X - self.Pos.X;
local gby = hit.Y - self.Pos.Y;
local curdist = math.sqrt(gbx ^ 2 + gby ^ 2);
if curdist < 25 then
local warped = Vector(0,0);
local warp = SceneMan:CastWeaknessRay(hit, (Vector(1,0):SetMagnitude(99999)):RadRotate(self.aim), 0, warped, 0, true);
if warp == true then
self.Pos = warped;
end
end
end
end