Hi Basically For My snaplines i want the outline to rotate around as the actual direction of the snapline changes, I keep fucking up the math but I'm Really close at the moment
Code:
local origin = v:GetPos();
snapendx = origin:ToScreen().x;
snapendy = origin:ToScreen().y;
snapstarty = ScrH()/2;
snapstartx = ScrW()/2;
local offsetx, offsety = SnapRotate();
if (math.abs(snapendx) < ScrW()*5 && math.abs(snapendy) < ScrH()*5) then
surface.SetDrawColor(5,5,5)
surface.DrawLine(snapstartx-offsetx, snapstarty-offsety, snapendx-offsetx, snapendy-offsety)
surface.DrawLine(snapstartx+offsetx, snapstarty+offsety, snapendx+offsetx, snapendy+offsety)
surface.SetDrawColor(color)
surface.DrawLine(snapstartx, snapstarty, snapendx, snapendy)
end
That's the actual snapline and this is the rotation func()
Code:
local function SnapRotate()
local _x = snapendx - snapstartx;
local _y = snapendy - snapstarty;
local snapangle = math.deg(math.atan2(_y,_x));
if (snapangle > 0 && snapangle < 90) then
_snapangle = 90 - snapangle;
__snapangle = _snapangle - 90;
elseif (snapangle > 90) then
_snapangle = (snapangle % 90);
__snapangle = 90 - _snapangle;
elseif (snapangle < 0 && snapangle > -90) then
_snapangle = 90 - math.abs(snapangle);
__snapangle = math.abs(snapangle);
elseif (snapangle < -90) then
_snapangle = math.abs(snapangle) % 90;
__snapangle = _snapangle - 90;
end
x = math.sin(math.rad(__snapangle));
y = math.sin(math.rad(_snapangle));
print(x,y)
return x, y;
end
It's Functional but not p; I was wondering if any of you guys were capable of getting this shit gud