function humanoidControl.setMode(E,I,B)E._mode=I if I==Enum.HumanoidControlType.Locked then E._lockedMoveVector=B end end function humanoidControl.getWorldMoveDirection(B,I)local E=I or B._mode if E==Enum.HumanoidControlType.Default then return B.humanoid.MoveDirection elseif E==Enum.HumanoidControlType.Locked then return B._lockedMoveVector elseif E==Enum.HumanoidControlType.Forced or E==Enum.HumanoidControlType.ForcedRespectCamera then local I=B.humanoid.MoveDirection local i=I:Dot(I)if E==Enum.HumanoidControlType.ForcedRespectCamera and i==0 then I=(CAMERA.CFrame.lookVector*Vector3.new(1,0,1)).unit i=1 end local D=B.hrp.CFrame.lookVector local k=math.atan2(-D.z,D.x)local S=i>0 and math.atan2(-I.z,I.x)or k B._forcedMoveVector=CFrame.fromEulerAnglesYXZ(0,S,0)*Vector3.new(1,0,0)return B._forcedMoveVector end end


function humanoidControl:setMode(newMode, moveVec)
	self._mode = newMode;
	if (newMode == Enum.HumanoidControlType.Locked) then
		self._lockedMoveVector = moveVec;
	end
end

function humanoidControl:getWorldMoveDirection(enum)
	local mode = enum or self._mode;
	
	if (mode == Enum.HumanoidControlType.Default) then
		return self.humanoid.MoveDirection;
	elseif (mode == Enum.HumanoidControlType.Locked) then
		return self._lockedMoveVector;
	elseif (mode == Enum.HumanoidControlType.Forced or mode == Enum.HumanoidControlType.ForcedRespectCamera) then
		local worldMove = self.humanoid.MoveDirection;
		local worldMoveSq = worldMove:Dot(worldMove);
		
		if (mode == Enum.HumanoidControlType.ForcedRespectCamera and worldMoveSq == 0) then
			worldMove = (CAMERA.CFrame.lookVector * Vector3.new(1, 0, 1)).unit;
			worldMoveSq = 1;
		end
		
		local look = self.hrp.CFrame.lookVector;
		local realTheta = math.atan2(-look.z, look.x);
		local worldTheta = worldMoveSq > 0 and math.atan2(-worldMove.z, worldMove.x) or realTheta;
		
		self._forcedMoveVector = CFrame.fromEulerAnglesYXZ(0, worldTheta, 0) * Vector3.new(1, 0, 0);
		
		return self._forcedMoveVector;
	end
end
