function BaseCamera.GetMeasuredDistanceToFocus(G)local f=game.Workspace.CurrentCamera if f then return(f.CoordinateFrame.p-f.Focus.p).magnitude end return nil end function BaseCamera.GetCameraLookVector(G)return game.Workspace.CurrentCamera and game.Workspace.CurrentCamera.CFrame.lookVector or UNIT_Z end function BaseCamera.CalculateNewLookCFrameFromArg(v,G,f)local e=G or v:GetCameraLookVector()local z=math.asin(e.y)local j=math.clamp(f.y,-MAX_Y+z,-MIN_Y+z)local r=Vector2.new(f.x,j)local b=CFrame.new(ZERO_VECTOR3,e)local Y=(CFrame.Angles(0,-r.x,0)*b)*CFrame.Angles(-r.y,0,0)return Y end function BaseCamera.CalculateNewLookVectorFromArg(v,G,f)local e=v:CalculateNewLookCFrameFromArg(G,f)return e.lookVector end function BaseCamera.CalculateNewLookVectorVRFromArg(f,G)local v=f:GetSubjectPosition()local e=v-game.Workspace.CurrentCamera.CFrame.p local z=(e*X1_Y0_Z1).unit local j=Vector2.new(G.x,0)local r=CFrame.new(ZERO_VECTOR3,z)local b=((CFrame.Angles(0,-j.x,0)*r)*CFrame.Angles(-j.y,0,0)).lookVector return(b*X1_Y0_Z1).unit end function BaseCamera.GetHumanoid(G)local f=player and player.Character if f then local v=G.humanoidCache[player]if v and v.Parent==f then return v else G.humanoidCache[player]=nil local v=f:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if v then G.humanoidCache[player]=v end return v end end return nil end function BaseCamera.GetHumanoidPartToFollow(v,G,f)if f==Enum.HumanoidStateType.Dead then local f=G.Parent if f then return f:FindFirstChild("\072\101\097\100")or G.Torso else return G.Torso end else return G.Torso end end

function BaseCamera:GetMeasuredDistanceToFocus()
	local camera = game.Workspace.CurrentCamera
	if camera then
		return (camera.CoordinateFrame.p - camera.Focus.p).magnitude
	end
	return nil
end

function BaseCamera:GetCameraLookVector()
	return game.Workspace.CurrentCamera and game.Workspace.CurrentCamera.CFrame.lookVector or UNIT_Z
end

function BaseCamera:CalculateNewLookCFrameFromArg(suppliedLookVector, rotateInput)
	local currLookVector = suppliedLookVector or self:GetCameraLookVector()
	local currPitchAngle = math.asin(currLookVector.y)
	local yTheta = math.clamp(rotateInput.y, -MAX_Y + currPitchAngle, -MIN_Y + currPitchAngle)
	local constrainedRotateInput = Vector2.new(rotateInput.x, yTheta)
	local startCFrame = CFrame.new(ZERO_VECTOR3, currLookVector)
	local newLookCFrame = CFrame.Angles(0, -constrainedRotateInput.x, 0) * startCFrame * CFrame.Angles(-constrainedRotateInput.y,0,0)
	return newLookCFrame
end

function BaseCamera:CalculateNewLookVectorFromArg(suppliedLookVector, rotateInput)
	local newLookCFrame = self:CalculateNewLookCFrameFromArg(suppliedLookVector, rotateInput)
	return newLookCFrame.lookVector
end

function BaseCamera:CalculateNewLookVectorVRFromArg(rotateInput)
	local subjectPosition = self:GetSubjectPosition()
	local vecToSubject = (subjectPosition - game.Workspace.CurrentCamera.CFrame.p)
	local currLookVector = (vecToSubject * X1_Y0_Z1).unit
	local vrRotateInput = Vector2.new(rotateInput.x, 0)
	local startCFrame = CFrame.new(ZERO_VECTOR3, currLookVector)
	local yawRotatedVector = (CFrame.Angles(0, -vrRotateInput.x, 0) * startCFrame * CFrame.Angles(-vrRotateInput.y,0,0)).lookVector
	return (yawRotatedVector * X1_Y0_Z1).unit
end

function BaseCamera:GetHumanoid()
	local character = player and player.Character
	if character then
		local resultHumanoid = self.humanoidCache[player]
		if resultHumanoid and resultHumanoid.Parent == character then
			return resultHumanoid
		else
			self.humanoidCache[player] = nil -- Bust Old Cache
			local humanoid = character:FindFirstChildOfClass("Humanoid")
			if humanoid then
				self.humanoidCache[player] = humanoid
			end
			return humanoid
		end
	end
	return nil
end

function BaseCamera:GetHumanoidPartToFollow(humanoid, humanoidStateType)
	if humanoidStateType == Enum.HumanoidStateType.Dead then
		local character = humanoid.Parent
		if character then
			return character:FindFirstChild("Head") or humanoid.Torso
		else
			return humanoid.Torso
		end
	else
		return humanoid.Torso
	end
end
