Introducing Portrait Mode & Dynamic Thumbstick

Device Orientation - Portrait Mode

We’re excited to announce that Roblox now supports portrait mode on mobile devices! With portrait mode, developers have the freedom to create new and exciting experiences that can be played with one hand, greatly broadening the scope of games on Roblox. We have added the following properties in Studio, allowing you to lock the orientation as needed or give players permission to dynamically switch between landscape and portrait mode in-game. More documentation can be found here on the developer wiki page.

  • StarterGui.ScreenOrientation: Determines the starting orientation for the device for all players.

  • Portrait

  • Landscape Right

  • Landscape Left

  • Sensor

  • Sensor Landscape (current default)

  • PlayerGui.ScreenOrientation: Immediately changes the orientation of the viewport on the client’s device to conform to the setting, so you can set orientation during a game, for an individual player.

  • PlayerGui.CurrentScreenOrientation: Obtains the current orientation of the device.

Dynamic Thumbstick

We’re also introducing an optional new control scheme designed specifically for portrait mode and one-handed gameplay, although it works well for landscape too! When “Dynamic Thumbstick” is enabled, it creates a virtual thumbstick when the player touches and drags their finger along the lower portion of the screen. This means it can be used by right- AND left-handed players. In addition, Dynamic Thumbstick also adds an auto-jump feature which forces your character to jump automatically over small ledges or gaps to provide a more streamlined experience. If you prefer, you can still tap on the lower portion of the screen to jump while moving or standing still.

The image below shows how the control scheme works in portrait mode. If you’re in landscape mode, the controls are exactly the same with the only difference being that now the bottom half of the screen (rather than the bottom ⅖ of the screen) is used for moving your character.

Portrait Mode in Studio

To emulate portrait mode in Studio, go to the “Test” tab, enable the emulator, and click on the rotate device button. Then, to enable the new portrait mode control scheme, go into the in-game settings and switch the control mode to “Dynamic Thumbstick.”

From a usability perspective, portrait mode allows players to play comfortably with one-hand - which comes in handy (no pun intended) if you’re playing on a train, for example. To play in portrait mode NOW, you can visit Natural Disaster Survival (by Stickmasterluke) or the fishing mini-game in MeepCity (by Alexnewtron) on your phone.

Natural Disaster Survival


MeepCity


We hope you enjoy playing and developing new experiences in portrait mode! We can’t wait to see what you come up with. Let us know what you think.

33 Likes

Sweet! To tag along with this, I made a little code snippet for people to use if they want their screen to rotate based on the device’s gravity. :slight_smile:

Please note that you can always use Sensor instead of this for a more optimized approach.

if UserInputService.AccelerometerEnabled then
	local o,t,n
	local a0 = 5 --initial acceleration to trigger the loop
	local a1 = 7 --average acceleration needed to transition
	UserInputService.DeviceGravityChanged:connect(function(input)

		if o then
			if tick() - t < .5 then
				n = n + 1
				o = o + input.Position
			else
				if player.PlayerGui.ScreenOrientation == Enum.ScreenOrientation.Portrait then
					--Z is positive when turned left
					--Z is negative when turned right
					if o.z/n > a1 then
						player.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeRight
					elseif o.z/n < -a1 then
						player.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeLeft
					end
				elseif player.PlayerGui.ScreenOrientation == Enum.ScreenOrientation.LandscapeRight then
					--X is negative when turned left
					--Z is negative when portrait
					if o.z/n < -a1 then
						player.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.Portrait
					elseif o.x/n < -a1 then
						player.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeLeft
					end
				elseif player.PlayerGui.ScreenOrientation == Enum.ScreenOrientation.LandscapeLeft then
					--X is negative when right
					--Z is positive when portrait
					if o.z/n > a1 then
						player.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.Portrait
					elseif o.x/n < -a1 then
						player.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeRight
					end
				end
				o = nil
			end
		else
			if input.Position.x > a0 or input.Position.x < -a0 or input.Position.z > a0 or input.Position.z < -a0 then
				t = tick()
				n = 1
				o = input.Position
			end
		end
	end)
end
3 Likes

You can just set PlayerGui.ScreenOrientation to Sensor though

I made this so users can get a better understanding as to how sensors can trigger screen rotation. It may not be the most optimized way, but if users want to learn from it, then so be it. :slight_smile:

1 Like

Woo, it’s finally out!

Just a small note to anyone who wants to use ScreenOrientation.Sensor:

Right now, there’s a minor issue with iOS where the orientation won’t update immediately if Sensor is set in StarterGui.ScreenOrientation. This is because I assumed iOS would handle this but it turns out it doesn’t. :frowning:

Fortunately, there’s a simple workaround! Just add this in a LocalScript in StarterPlayerScripts:

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")

if PlayerGui.ScreenOrientation == Enum.ScreenOrientation.Sensor then
     PlayerGui.ScreenOrientation = Enum.ScreenOrientation.Portrait
     wait()
     PlayerGui.ScreenOrientation = Enum.ScreenOrientation.Sensor
end

This forces the OS to update the screen orientation. This will be fixed soon.

Also, we currently have to rebuild the graphics context on Android whenever the screen resolution changes. This will cause minor visual artifacts for a very short time after switching orientation, but it shouldn’t harm gameplay. We’re also going to fix this soon. Don’t be alarmed if your game looks a little… gray for a second.

7 Likes

Check out NDS today if you’d like to see the sensor mode in action.

NOTE - we’ll be looking for top games that use portrait mode, potentially for future marketing efforts. If you are supporting Portrait Mode or Sensor Mode, post your game in this thread so we know about it.

Also, if you experience any issues with this new mode, or with the dynamic thumbstick, let us know!

1 Like

There are a few known issues using backpack items with the Dynamic Thumbstick that we will be addressing.

When you have an item that requires a tap to use (sword, gun, etc.) you can tap anywhere on the screen to use the item. In order to support this, we have turned tap to Jump OFF. You can still auto-jump over objects as you move your character around. Tap to Jump is enabled again, when you put the backpack item away.

When you have an item equipped that is passive (does not require user input to function), or you have an item that requires jump to use (balloon in NDS), the Jump functionality is still turned OFF. We will fix this so you can still jump for passive and jump triggered backpack items.

2 Likes

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.