I’ve created a mobile button that’s capable of toggling between a first person view similar to VR and the default camera. It uses your mobile device’s gyroscope + accelerometer to fluidly change your camera’s CFrame.
The main benefit of this mobile camera controller is that it supports both portrait and landscape mode.
Poor video representation (since I didn’t have any external cameras at my disposal, to record myself interacting with the mobile device)
This code was made to improve mobile UX - This should prove to be a more ergonomic replacement for the default first person camera on mobile.
Uncopylocked demonstration place
𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻
PlayerGui.CurrentScreenOrientation
does not return whether a player is in portrait or any type of landscape mode when the screenorientation is set to Sensor
- which means you’ll have to figure that out with some other code (which is provided in my place)
Related Developer hub pages
UserInputService.GyroscopeEnabled
UserInputService:GetDeviceRotation
UserInputService:GetDeviceGravity
I’ve left all my comments inside the code as to show some of the pitfalls I’ve dealt with. There is also a disabled screenGUI inside the place which can be used for debugging.