local x=game:GetService("\086\082\083\101\114\118\105\099\101")local g=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local u=game:GetService("\082\117\110\083\101\114\118\105\099\101")local e=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")local Y=game:GetService("\067\111\110\116\101\120\116\065\099\116\105\111\110\083\101\114\118\105\099\101")local v=game:GetService("\083\116\097\114\116\101\114\071\117\105")local R=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer local G=Vector3.new(0,0,0)local E=Vector3.new(1,0,1)local function r(x)local g=false if x==x then g=false if x~=1/0 then g=x~=-1/0 end end return g end local j=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")j.Name="\077\111\118\101\109\101\110\116\085\112\100\097\116\101"j.Parent=script local V=nil;(coroutine.wrap(function()local x=script.Parent:WaitForChild("\080\097\116\104\068\105\115\112\108\097\121")if x then V=require(x)end end))()local W=require(script.Parent:WaitForChild("\066\097\115\101\067\104\097\114\097\099\116\101\114\067\111\110\116\114\111\108\108\101\114"))local U=setmetatable({},W)U.__index=U function U.new(x)local g=setmetatable(W.new(),U)g.CONTROL_ACTION_PRIORITY=x g.navigationRequestedConn=nil g.heartbeatConn=nil g.currentDestination=nil g.currentPath=nil g.currentPoints=nil g.currentPointIdx=0 g.expectedTimeToNextPoint=0 g.timeReachedLastPoint=tick()g.moving=false g.isJumpBound=false g.moveLatch=false g.userCFrameEnabledConn=nil return g end function U.SetLaserPointerMode(x,g)pcall(function()v:SetCore("\086\082\076\097\115\101\114\080\111\105\110\116\101\114\077\111\100\101",g)end)end function U.GetLocalHumanoid(x)local g=R.Character if not g then return end for x,g in pairs(g:GetChildren())do if g:IsA("\072\117\109\097\110\111\105\100")then return g end end return nil end function U.HasBothHandControllers(g)return x:GetUserCFrameEnabled(Enum.UserCFrame.RightHand)and x:GetUserCFrameEnabled(Enum.UserCFrame.LeftHand)end function U.HasAnyHandControllers(g)return x:GetUserCFrameEnabled(Enum.UserCFrame.RightHand)or x:GetUserCFrameEnabled(Enum.UserCFrame.LeftHand)end function U.IsMobileVR(x)return g.TouchEnabled end function U.HasGamepad(x)return g.GamepadEnabled end function U.ShouldUseNavigationLaser(x)if x:IsMobileVR()then return true end if x:HasBothHandControllers()then return false end if x:HasAnyHandControllers()then return true end return not x:HasGamepad()end function U.StartFollowingPath(x,g)currentPath=g currentPoints=currentPath:GetPointCoordinates()currentPointIdx=1 moving=true timeReachedLastPoint=tick()local u=x:GetLocalHumanoid()if u and(u.Torso and#currentPoints>=1)then expectedTimeToNextPoint=(currentPoints[1]-u.Torso.Position).magnitude/u.WalkSpeed end j:Fire("\116\097\114\103\101\116\080\111\105\110\116",x.currentDestination)end function U.GoToPoint(x,g)currentPath=true currentPoints={g}currentPointIdx=1 moving=true local u=x:GetLocalHumanoid()timeReachedLastPoint=tick()expectedTimeToNextPoint=(u.Torso.Position-g).magnitude/u.WalkSpeed j:Fire("\116\097\114\103\101\116\080\111\105\110\116",g)end function U.StopFollowingPath(x)currentPath=nil currentPoints=nil currentPointIdx=0 moving=false x.moveVector=G end function U.TryComputePath(x,g,u)local Y=nil while not Y and true do local x=e:ComputeSmoothPathAsync(g,u,200)if x.Status==Enum.PathStatus.ClosestNoPath then return nil end if x.Status==Enum.PathStatus.ClosestOutOfRange then return nil end if x and x.Status==Enum.PathStatus.FailStartNotEmpty then g=g+(u-g).unit x=nil end if Y and Y.Status==Enum.PathStatus.FailFinishNotEmpty then u=u+Vector3.new(0,1,0)Y=nil end end return Y end local function l(x)return r(x.x)and(r(x.y)and r(x.z))end function U.OnNavigationRequest(x,g,u)local e=g.p local Y=x.currentDestination if not l(e)then return end x.currentDestination=e local v=x:GetLocalHumanoid()if not v or not v.Torso then return end local R=v.Torso.Position if(x.currentDestination-R).magnitude<12 then x:GoToPoint(x.currentDestination)return end if not Y or(x.currentDestination-Y).magnitude>4 then local g=x:TryComputePath(R,x.currentDestination)if g then x:StartFollowingPath(g)if V then V.setCurrentPoints(x.currentPoints)V.renderPath()return end else x:StopFollowingPath()if V then V.clearRenderedPath()return end end else if moving then x.currentPoints[#currentPoints]=x.currentDestination return end x:GoToPoint(x.currentDestination)end end function U.OnJumpAction(x,g,u,e)if u==Enum.UserInputState.Begin then x.isJumping=true end return Enum.ContextActionResult.Sink end function U.BindJumpAction(x,g)if g then if x.isJumpBound then return end else if x.isJumpBound then x.isJumpBound=false Y:UnbindAction("\086\082\074\117\109\112\065\099\116\105\111\110")end return end x.isJumpBound=true Y:BindActionAtPriority("\086\082\074\117\109\112\065\099\116\105\111\110",function()return x:OnJumpAction()end,false,x.CONTROL_ACTION_PRIORITY,Enum.KeyCode.ButtonA)end function U.ControlCharacterGamepad(x,g,u,e)if e.KeyCode~=Enum.KeyCode.Thumbstick1 then return end if u==Enum.UserInputState.Cancel then x.moveVector=G return end if u~=Enum.UserInputState.End then x:StopFollowingPath()if V then V.clearRenderedPath()end if x:ShouldUseNavigationLaser()then x:BindJumpAction(true)x:SetLaserPointerMode("\072\105\100\100\101\110")end if e.Position.magnitude>.22 then x.moveVector=Vector3.new(e.Position.X,0,-e.Position.Y)if x.moveVector.magnitude>0 then x.moveVector=x.moveVector.unit*math.min(1,e.Position.magnitude)end x.moveLatch=true end else x.moveVector=G if x:ShouldUseNavigationLaser()then x:BindJumpAction(false)x:SetLaserPointerMode("\078\097\118\105\103\097\116\105\111\110")end if x.moveLatch then x.moveLatch=false j:Fire("\111\102\102\116\114\097\099\107")end end return Enum.ContextActionResult.Sink end function U.OnHeartbeat(x,g)local u=x.moveVector local e=x:GetLocalHumanoid()if not e or not e.Torso then return end if x.moving and x.currentPoints then local Y=e.Torso.Position local v=(currentPoints[1]-Y)*E local R=v.magnitude local G=v/R if R<1 then local g=0 local u=currentPoints[1]for x,Y in pairs(currentPoints)do if x~=1 then u=Y g=g+(Y-u).magnitude/e.WalkSpeed end end table.remove(currentPoints,1)currentPointIdx=currentPointIdx+1 if#currentPoints==0 then x:StopFollowingPath()if V then V.clearRenderedPath()end return end if V then V.setCurrentPoints(currentPoints)V.renderPath()end expectedTimeToNextPoint=(currentPoints[1]-Y).magnitude/e.WalkSpeed timeReachedLastPoint=tick()else local v={game.Players.LocalPlayer.Character;workspace.CurrentCamera}local R,E,r=workspace:FindPartOnRayWithIgnoreList(Ray.new(Y-Vector3.new(0,1,0),G*3),v)if R then local x=Vector3.new(0,100,0)local g,u,R=workspace:FindPartOnRayWithIgnoreList(Ray.new((E+G*.5)+x,-x),v)local r=u.Y-Y.Y if r<6 and r>-2 then e.Jump=true end end if expectedTimeToNextPoint+2<tick()-timeReachedLastPoint then x:StopFollowingPath()if V then V.clearRenderedPath()end j:Fire("\111\102\102\116\114\097\099\107")end u=x.moveVector:Lerp(G,g*10)end end if l(u)then x.moveVector=u end end function U.OnUserCFrameEnabled(x)if x:ShouldUseNavigationLaser()then x:BindJumpAction(false)x:SetLaserPointerMode("\078\097\118\105\103\097\116\105\111\110")return end x:BindJumpAction(true)x:SetLaserPointerMode("\072\105\100\100\101\110")end function U.Enable(g,e)g.moveVector=G g.isJumping=false if e then g.navigationRequestedConn=x.NavigationRequested:Connect(function(x,u)g:OnNavigationRequest(x,u)end)g.heartbeatConn=u.Heartbeat:Connect(function(x)g:OnHeartbeat(x)end)Y:BindAction("\077\111\118\101\084\104\117\109\098\115\116\105\099\107",function(x,u,e)return g:ControlCharacterGamepad(x,u,e)end,false,g.CONTROL_ACTION_PRIORITY,Enum.KeyCode.Thumbstick1)Y:BindActivate(Enum.UserInputType.Gamepad1,Enum.KeyCode.ButtonR2)g.userCFrameEnabledConn=x.UserCFrameEnabled:Connect(function()g:OnUserCFrameEnabled()end)g:OnUserCFrameEnabled()x:SetTouchpadMode(Enum.VRTouchpad.Left,Enum.VRTouchpadMode.VirtualThumbstick)x:SetTouchpadMode(Enum.VRTouchpad.Right,Enum.VRTouchpadMode.ABXY)g.enabled=true return end g:StopFollowingPath()Y:UnbindAction("\077\111\118\101\084\104\117\109\098\115\116\105\099\107")Y:UnbindActivate(Enum.UserInputType.Gamepad1,Enum.KeyCode.ButtonR2)g:BindJumpAction(false)g:SetLaserPointerMode("\068\105\115\097\098\108\101\100")if g.navigationRequestedConn then g.navigationRequestedConn:Disconnect()g.navigationRequestedConn=nil end if g.heartbeatConn then g.heartbeatConn:Disconnect()g.heartbeatConn=nil end if g.userCFrameEnabledConn then g.userCFrameEnabledConn:Disconnect()g.userCFrameEnabledConn=nil end g.enabled=false end return U


local l__VRService__1 = game:GetService("VRService");
local l__UserInputService__2 = game:GetService("UserInputService");
local l__RunService__3 = game:GetService("RunService");
local l__PathfindingService__4 = game:GetService("PathfindingService");
local l__ContextActionService__5 = game:GetService("ContextActionService");
local l__StarterGui__6 = game:GetService("StarterGui");
local l__LocalPlayer__7 = game:GetService("Players").LocalPlayer;
local v8 = Vector3.new(0, 0, 0);
local v9 = Vector3.new(1, 0, 1);
local function u1(p1)
	local v10 = false;
	if p1 == p1 then
		v10 = false;
		if p1 ~= (1 / 0) then
			v10 = p1 ~= (-1 / 0);
		end;
	end;
	return v10;
end;
local v11 = Instance.new("BindableEvent");
v11.Name = "MovementUpdate";
v11.Parent = script;
local u2 = nil;
coroutine.wrap(function()
	local l__PathDisplay__12 = script.Parent:WaitForChild("PathDisplay");
	if l__PathDisplay__12 then
		u2 = require(l__PathDisplay__12);
	end;
end)();
local v13 = require(script.Parent:WaitForChild("BaseCharacterController"));
local v14 = setmetatable({}, v13);
v14.__index = v14;
function v14.new(p2)
	local v15 = setmetatable(v13.new(), v14);
	v15.CONTROL_ACTION_PRIORITY = p2;
	v15.navigationRequestedConn = nil;
	v15.heartbeatConn = nil;
	v15.currentDestination = nil;
	v15.currentPath = nil;
	v15.currentPoints = nil;
	v15.currentPointIdx = 0;
	v15.expectedTimeToNextPoint = 0;
	v15.timeReachedLastPoint = tick();
	v15.moving = false;
	v15.isJumpBound = false;
	v15.moveLatch = false;
	v15.userCFrameEnabledConn = nil;
	return v15;
end;
function v14.SetLaserPointerMode(p3, p4)
	pcall(function()
		l__StarterGui__6:SetCore("VRLaserPointerMode", p4);
	end);
end;
function v14.GetLocalHumanoid(p5)
	local l__Character__16 = l__LocalPlayer__7.Character;
	if not l__Character__16 then
		return;
	end;
	for v17, v18 in pairs(l__Character__16:GetChildren()) do
		if v18:IsA("Humanoid") then
			return v18;
		end;
	end;
	return nil;
end;
function v14.HasBothHandControllers(p6)
	return l__VRService__1:GetUserCFrameEnabled(Enum.UserCFrame.RightHand) and l__VRService__1:GetUserCFrameEnabled(Enum.UserCFrame.LeftHand);
end;
function v14.HasAnyHandControllers(p7)
	return l__VRService__1:GetUserCFrameEnabled(Enum.UserCFrame.RightHand) or l__VRService__1:GetUserCFrameEnabled(Enum.UserCFrame.LeftHand);
end;
function v14.IsMobileVR(p8)
	return l__UserInputService__2.TouchEnabled;
end;
function v14.HasGamepad(p9)
	return l__UserInputService__2.GamepadEnabled;
end;
function v14.ShouldUseNavigationLaser(p10)
	if p10:IsMobileVR() then
		return true;
	end;
	if p10:HasBothHandControllers() then
		return false;
	end;
	if p10:HasAnyHandControllers() then
		return true;
	end;
	return not p10:HasGamepad();
end;
function v14.StartFollowingPath(p11, p12)
	currentPath = p12;
	currentPoints = currentPath:GetPointCoordinates();
	currentPointIdx = 1;
	moving = true;
	timeReachedLastPoint = tick();
	local v19 = p11:GetLocalHumanoid();
	if v19 and v19.Torso and #currentPoints >= 1 then
		expectedTimeToNextPoint = (currentPoints[1] - v19.Torso.Position).magnitude / v19.WalkSpeed;
	end;
	v11:Fire("targetPoint", p11.currentDestination);
end;
function v14.GoToPoint(p13, p14)
	currentPath = true;
	currentPoints = { p14 };
	currentPointIdx = 1;
	moving = true;
	local v20 = p13:GetLocalHumanoid();
	timeReachedLastPoint = tick();
	expectedTimeToNextPoint = (v20.Torso.Position - p14).magnitude / v20.WalkSpeed;
	v11:Fire("targetPoint", p14);
end;
function v14.StopFollowingPath(p15)
	currentPath = nil;
	currentPoints = nil;
	currentPointIdx = 0;
	moving = false;
	p15.moveVector = v8;
end;
function v14.TryComputePath(p16, p17, p18)
	local v21 = nil;
	while not v21 and 0 < 5 do
		local v22 = l__PathfindingService__4:ComputeSmoothPathAsync(p17, p18, 200);
		if v22.Status == Enum.PathStatus.ClosestNoPath then
			return nil;
		end;
		if v22.Status == Enum.PathStatus.ClosestOutOfRange then
			return nil;
		end;
		if v22 and v22.Status == Enum.PathStatus.FailStartNotEmpty then
			p17 = p17 + (p18 - p17).unit;
			v22 = nil;
		end;
		if v21 and v21.Status == Enum.PathStatus.FailFinishNotEmpty then
			p18 = p18 + Vector3.new(0, 1, 0);
			v21 = nil;
		end;	
	end;
	return v21;
end;
local function u3(p19)
	return u1(p19.x) and (u1(p19.y) and u1(p19.z));
end;
function v14.OnNavigationRequest(p20, p21, p22)
	local l__p__23 = p21.p;
	local l__currentDestination__24 = p20.currentDestination;
	if not u3(l__p__23) then
		return;
	end;
	p20.currentDestination = l__p__23;
	local v25 = p20:GetLocalHumanoid();
	if not v25 or not v25.Torso then
		return;
	end;
	local l__Position__26 = v25.Torso.Position;
	if (p20.currentDestination - l__Position__26).magnitude < 12 then
		p20:GoToPoint(p20.currentDestination);
		return;
	end;
	if not l__currentDestination__24 or (p20.currentDestination - l__currentDestination__24).magnitude > 4 then
		local v27 = p20:TryComputePath(l__Position__26, p20.currentDestination);
		if v27 then
			p20:StartFollowingPath(v27);
			if u2 then
				u2.setCurrentPoints(p20.currentPoints);
				u2.renderPath();
				return;
			end;
		else
			p20:StopFollowingPath();
			if u2 then
				u2.clearRenderedPath();
				return;
			end;
		end;
	else
		if moving then
			p20.currentPoints[#currentPoints] = p20.currentDestination;
			return;
		end;
		p20:GoToPoint(p20.currentDestination);
	end;
end;
function v14.OnJumpAction(p23, p24, p25, p26)
	if p25 == Enum.UserInputState.Begin then
		p23.isJumping = true;
	end;
	return Enum.ContextActionResult.Sink;
end;
function v14.BindJumpAction(p27, p28)
	if p28 then
		if p27.isJumpBound then
			return;
		end;
	else
		if p27.isJumpBound then
			p27.isJumpBound = false;
			l__ContextActionService__5:UnbindAction("VRJumpAction");
		end;
		return;
	end;
	p27.isJumpBound = true;
	l__ContextActionService__5:BindActionAtPriority("VRJumpAction", function()
		return p27:OnJumpAction();
	end, false, p27.CONTROL_ACTION_PRIORITY, Enum.KeyCode.ButtonA);
end;
function v14.ControlCharacterGamepad(p29, p30, p31, p32)
	if p32.KeyCode ~= Enum.KeyCode.Thumbstick1 then
		return;
	end;
	if p31 == Enum.UserInputState.Cancel then
		p29.moveVector = v8;
		return;
	end;
	if p31 ~= Enum.UserInputState.End then
		p29:StopFollowingPath();
		if u2 then
			u2.clearRenderedPath();
		end;
		if p29:ShouldUseNavigationLaser() then
			p29:BindJumpAction(true);
			p29:SetLaserPointerMode("Hidden");
		end;
		if p32.Position.magnitude > 0.22 then
			p29.moveVector = Vector3.new(p32.Position.X, 0, -p32.Position.Y);
			if p29.moveVector.magnitude > 0 then
				p29.moveVector = p29.moveVector.unit * math.min(1, p32.Position.magnitude);
			end;
			p29.moveLatch = true;
		end;
	else
		p29.moveVector = v8;
		if p29:ShouldUseNavigationLaser() then
			p29:BindJumpAction(false);
			p29:SetLaserPointerMode("Navigation");
		end;
		if p29.moveLatch then
			p29.moveLatch = false;
			v11:Fire("offtrack");
		end;
	end;
	return Enum.ContextActionResult.Sink;
end;
function v14.OnHeartbeat(p33, p34)
	local v28 = p33.moveVector;
	local v29 = p33:GetLocalHumanoid();
	if not v29 or not v29.Torso then
		return;
	end;
	if p33.moving and p33.currentPoints then
		local l__Position__30 = v29.Torso.Position;
		local v31 = (currentPoints[1] - l__Position__30) * v9;
		local l__magnitude__32 = v31.magnitude;
		local v33 = v31 / l__magnitude__32;
		if l__magnitude__32 < 1 then
			local v34 = 0;
			local v35 = currentPoints[1];
			for v36, v37 in pairs(currentPoints) do
				if v36 ~= 1 then
					v35 = v37;
					v34 = v34 + (v37 - v35).magnitude / v29.WalkSpeed;
				end;
			end;
			table.remove(currentPoints, 1);
			currentPointIdx = currentPointIdx + 1;
			if #currentPoints == 0 then
				p33:StopFollowingPath();
				if u2 then
					u2.clearRenderedPath();
				end;
				return;
			end;
			if u2 then
				u2.setCurrentPoints(currentPoints);
				u2.renderPath();
			end;
			expectedTimeToNextPoint = (currentPoints[1] - l__Position__30).magnitude / v29.WalkSpeed;
			timeReachedLastPoint = tick();
		else
			local v38 = { game.Players.LocalPlayer.Character, workspace.CurrentCamera };
			local v39, v40, v41 = workspace:FindPartOnRayWithIgnoreList(Ray.new(l__Position__30 - Vector3.new(0, 1, 0), v33 * 3), v38);
			if v39 then
				local v42 = Vector3.new(0, 100, 0);
				local v43, v44, v45 = workspace:FindPartOnRayWithIgnoreList(Ray.new(v40 + v33 * 0.5 + v42, -v42), v38);
				local v46 = v44.Y - l__Position__30.Y;
				if v46 < 6 and v46 > -2 then
					v29.Jump = true;
				end;
			end;
			if expectedTimeToNextPoint + 2 < tick() - timeReachedLastPoint then
				p33:StopFollowingPath();
				if u2 then
					u2.clearRenderedPath();
				end;
				v11:Fire("offtrack");
			end;
			v28 = p33.moveVector:Lerp(v33, p34 * 10);
		end;
	end;
	if u3(v28) then
		p33.moveVector = v28;
	end;
end;
function v14.OnUserCFrameEnabled(p35)
	if p35:ShouldUseNavigationLaser() then
		p35:BindJumpAction(false);
		p35:SetLaserPointerMode("Navigation");
		return;
	end;
	p35:BindJumpAction(true);
	p35:SetLaserPointerMode("Hidden");
end;
function v14.Enable(p36, p37)
	p36.moveVector = v8;
	p36.isJumping = false;
	if p37 then
		p36.navigationRequestedConn = l__VRService__1.NavigationRequested:Connect(function(p38, p39)
			p36:OnNavigationRequest(p38, p39);
		end);
		p36.heartbeatConn = l__RunService__3.Heartbeat:Connect(function(p40)
			p36:OnHeartbeat(p40);
		end);
		l__ContextActionService__5:BindAction("MoveThumbstick", function(p41, p42, p43)
			return p36:ControlCharacterGamepad(p41, p42, p43);
		end, false, p36.CONTROL_ACTION_PRIORITY, Enum.KeyCode.Thumbstick1);
		l__ContextActionService__5:BindActivate(Enum.UserInputType.Gamepad1, Enum.KeyCode.ButtonR2);
		p36.userCFrameEnabledConn = l__VRService__1.UserCFrameEnabled:Connect(function()
			p36:OnUserCFrameEnabled();
		end);
		p36:OnUserCFrameEnabled();
		l__VRService__1:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.VirtualThumbstick);
		l__VRService__1:SetTouchpadMode(Enum.VRTouchpad.Right, Enum.VRTouchpadMode.ABXY);
		p36.enabled = true;
		return;
	end;
	p36:StopFollowingPath();
	l__ContextActionService__5:UnbindAction("MoveThumbstick");
	l__ContextActionService__5:UnbindActivate(Enum.UserInputType.Gamepad1, Enum.KeyCode.ButtonR2);
	p36:BindJumpAction(false);
	p36:SetLaserPointerMode("Disabled");
	if p36.navigationRequestedConn then
		p36.navigationRequestedConn:Disconnect();
		p36.navigationRequestedConn = nil;
	end;
	if p36.heartbeatConn then
		p36.heartbeatConn:Disconnect();
		p36.heartbeatConn = nil;
	end;
	if p36.userCFrameEnabledConn then
		p36.userCFrameEnabledConn:Disconnect();
		p36.userCFrameEnabledConn = nil;
	end;
	p36.enabled = false;
end;
return v14;
