local function o(o)local p=((hrp.CFrame*CFrame.new(0,3,0)):pointToObjectSpace(o)).unit local O=-math.atan2(p.x,-p.z)local K=math.asin(p.y)local T=Vector3.new()if not(math.abs(O)>settings.horizontalRange or math.abs(K)>settings.verticalRange)then local o,p=math.sign(O),math.abs(O)local y,a=p*.5,p*.5 if a>settings.maxHorizontalWaist then local o=a-settings.maxHorizontalWaist a=settings.maxHorizontalWaist y=math.clamp(y+o,0,settings.maxHorizontalHead)end T=Vector3.new(o*y,o*a,K)end return T end


local function lookAt(target)
	local eye = (hrp.CFrame * CFrame.new(0, 3, 0)):pointToObjectSpace(target).unit;
	local horizontal = -math.atan2(eye.x, -eye.z);
	local vertical = math.asin(eye.y);
	
	local goal = Vector3.new();
	if not (math.abs(horizontal) > settings.horizontalRange or math.abs(vertical) > settings.verticalRange) then
		local hsign, habs = math.sign(horizontal), math.abs(horizontal);
		local hneck, hwaist = habs*0.5, habs*0.5;
		
		if (hwaist > settings.maxHorizontalWaist) then
			local remainder = hwaist - settings.maxHorizontalWaist;
			hwaist = settings.maxHorizontalWaist;
			hneck = math.clamp(hneck + remainder, 0, settings.maxHorizontalHead);
		end
		
		goal = Vector3.new(hsign*hneck, hsign*hwaist, vertical);
	end
	
	return goal;
end
