local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera -- Configuración ajustada para móvil local SENSITIVITY = 1.2 local EYE_SEPARATION = 0.06 -- Separación sutil entre ojos (en studs) local vrEnabled = false -- Variables de orientación local yaw = 0 local pitch = 0 local baseGyro = nil -- Crear GUI simple con botón de activar/desactivar para móvil local function createVRGui() local playerGui = player:WaitForChild("PlayerGui") local screenGui = Instance.new("ScreenGui") screenGui.Name = "FakeVRMobileGui" screenGui.ResetOnSpawn = false screenGui.IgnoreGuiInset = true screenGui.Parent = playerGui -- Botón para alternar VR local toggleBtn = Instance.new("TextButton") toggleBtn.Name = "ToggleVRButton" toggleBtn.Size = UDim2.new(0, 140, 0, 44) toggleBtn.Position = UDim2.new(0.5, -70, 0, 20) toggleBtn.BackgroundColor3 = Color3.fromRGB(30, 30, 35) toggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255) toggleBtn.Font = Enum.Font.GothamBold toggleBtn.TextSize = 14 toggleBtn.Text = "Activar VR Falso" toggleBtn.Parent = screenGui local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 10) corner.Parent = toggleBtn -- Divisoria central estilo visor VR (dos mitades con borde) local leftLens = Instance.new("Frame") leftLens.Name = "LeftLens" leftLens.Size = UDim2.new(0.5, 0, 1, 0) leftLens.Position = UDim2.new(0, 0, 0, 0) leftLens.BackgroundTransparency = 1 leftLens.Visible = false leftLens.Parent = screenGui local rightLens = Instance.new("Frame") rightLens.Name = "RightLens" rightLens.Size = UDim2.new(0.5, 0, 1, 0) rightLens.Position = UDim2.new(0.5, 0, 0, 0) rightLens.BackgroundTransparency = 1 rightLens.Visible = false rightLens.Parent = screenGui -- Línea divisoria central local divider = Instance.new("Frame") divider.Name = "CenterDivider" divider.Size = UDim2.new(0, 4, 1, 0) divider.Position = UDim2.new(0.5, -2, 0, 0) divider.BackgroundColor3 = Color3.fromRGB(10, 10, 10) divider.BorderSizePixel = 0 divider.Visible = false divider.Parent = screenGui -- Viñeta suave en cada ojo para simular lentes for _, lens in ipairs({ leftLens, rightLens }) do local stroke = Instance.new("UIStroke") stroke.Color = Color3.fromRGB(15, 15, 15) stroke.Thickness = 18 stroke.Transparency = 0.25 stroke.Parent = lens end return toggleBtn, leftLens, rightLens, divider end local toggleBtn, leftLens, rightLens, divider = createVRGui() local function setVREnabled(state: boolean) vrEnabled = state leftLens.Visible = vrEnabled rightLens.Visible = vrEnabled divider.Visible = vrEnabled if vrEnabled then toggleBtn.Text = "Desactivar VR" camera.CameraType = Enum.CameraType.Scriptable local character = player.Character local head = character and character:FindFirstChild("Head") if head then local _, yRot, _ = camera.CFrame:ToOrientation() yaw = yRot pitch = 0 end if UserInputService.GyroscopeEnabled then local _, gyroCf = UserInputService:GetGyroscopeCFrame() baseGyro = gyroCf else baseGyro = nil end else toggleBtn.Text = "Activar VR Falso" camera.CameraType = Enum.CameraType.Custom end end toggleBtn.MouseButton1Click:Connect(function() setVREnabled(not vrEnabled) end) -- Control táctil de respaldo si el teléfono no tiene giroscopio o al arrastrar UserInputService.TouchMoved:Connect(function(touch, gameProcessed) if not vrEnabled or gameProcessed then return end if touch.Position.X > camera.ViewportSize.X * 0.25 then yaw -= touch.Delta.X * 0.004 * SENSITIVITY pitch = math.clamp(pitch - touch.Delta.Y * 0.004 * SENSITIVITY, math.rad(-80), math.rad(80)) end end) -- Actualizar cámara cada frame RunService.RenderStepped:Connect(function(dt) if not vrEnabled then return end local character = player.Character local rootPart = character and character:FindFirstChild("HumanoidRootPart") local head = character and character:FindFirstChild("Head") if not rootPart or not head then return end local finalYaw = yaw local finalPitch = pitch -- Combinar con giroscopio si está disponible en el dispositivo móvil if UserInputService.GyroscopeEnabled then local _, gyroCf = UserInputService:GetGyroscopeCFrame() if not baseGyro then baseGyro = gyroCf end local deltaGyro = baseGyro:ToObjectSpace(gyroCf) local gPitch, gYaw, _ = deltaGyro:ToEulerAnglesYXZ() finalYaw -= gYaw * SENSITIVITY finalPitch = math.clamp(finalPitch + gPitch * SENSITIVITY, math.rad(-80), math.rad(80)) end local originPos = head.Position + Vector3.new(0, 0.3, 0) local rotation = CFrame.fromOrientation(finalPitch, finalYaw, 0) -- Desplazamiento sutil lateral para simular paralaje de ojo local eyeOffset = rotation.RightVector * (EYE_SEPARATION * 0.5) camera.CFrame = CFrame.new(originPos + eyeOffset) * rotation end)