Over the last few months, I found an app which I forget where you can see the skies and the stars on your phone and you can do that by rotating it. It’s kind of like VR but you don’t wear it and you only just hold your phone. (Example if you face your phone up, the camera in game will face up. If your phone is facing to the left, the camera in game will face to the left.
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local character = script.Parent
local head = character:WaitForChild("Head")
local lastInputFrame
local currentRotation = 0
local function GravityChanged(gravity)
if not orientationSet then
upsideDown = (gravity.Position.X < -.5 or gravity.Position.Z > .5)
orientationSet = true
end
end
local function RotationChanged(rotation, rotCFrame)
if orientationSet then
if not lastInputFrame then
lastInputFrame = rotCFrame
end
local delta = rotCFrame * lastInputFrame:inverse()
local x,y,z = delta:toEulerAnglesXYZ()
if upsideDown then
delta = CFrame.Angles(-x, y, z)
else
delta = CFrame.Angles(x, -y, z)
end
currentRotation = currentRotation * delta
lastInputFrame = rotCFrame
end
end
local function HideCharacter()
for _, limb in pairs (character:GetChildren()) do
if limb:IsA("Part") then
limb.Transparency = 1
end
end
end
local function UpdateCamera()
local camera = game.Workspace.CurrentCamera
camera.CoordinateFrame = currentRotation
camera.Focus = CFrame.new(currentRotation * Vector3.new(0,0,-10))
end
if UserInputService.GyroscopeEnabled then
UserInputService.DeviceGravityChanged:Connect(GravityChanged)
UserInputService.DeviceRotationChanged:Connect(RotationChanged)
HideCharacter()
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, function()
camera.CFrame = CFrame.new(head.Position - Vector3.new(0,8,10)) * currentRotation
camera.Focus = CFrame.new(currentRotation * Vector3.new(0,0,-10))
end)
end
local gyroIsEnabled = UserInputService.GyroscopeEnabled
if (gyroIsEnabled) then
print("Gyroscope is enabled!")
else
print("Gyroscope is not enabled!")
end
RunService.RenderStepped:Connect(function(dt)
UpdateCamera()
end)
New to this so idk how it works and how to set up.