Mobile "VR" Camera Lock

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) :point_down:

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 :point_down:

𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻

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

Understanding CFrames

UserInputService.GyroscopeEnabled

UserInputService:GetDeviceRotation

UserInputService:GetDeviceGravity

ScreenOrientation

UserInputService.AccelerometerEnabled

Accel Test - Roblox

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.

71 Likes

This was really awesome! I was surprised by how well it worked!
Amazing job!
On my iPhone 7, In portrait mode, I would have to flip my phone upside down otherwise it would be inverted, (Probably just me) But both ways worked really well in landscape.

7 Likes

Woah… This works great on the pixel 4. Glad I saw this, might try making a game using this, thank you so much!

3 Likes

Looks really awesome! I may use this for a future project of mine

1 Like

I’ve been looking for something like this for MONTHS! Thank you so much!

1 Like

This is officially my favorite post. This will help so much in exploration type games

1 Like

came because of the game, very interesting!

1 Like

I am surprised not a lot of people use this