PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Device Orientation

Device Orientation

Jul 02 2018, 5:22 PM PST 5 min

The orientation of a player’s device can have profound impacts on gameplay. For example:

  • Portrait mode often lends itself to one finger gameplay
  • Landscape mode is often intended for multiple fingers.

By default Roblox supports both portrait and landscape, allowing the game to switch between as needed. Games can be configured to switch orientation automatically as the player’s device rotates, or can be locked into a particular orientation if desired.

Orientation Modes

There are five different orientation modes that a device can be in. These include three locked modes (Landscape Left, Landscape Right, and Portrait) and two sensor modes (Sensor and Landscape Sensor). Note that Roblox does not include an upside-down portrait mode as many devices do not natively support that orientation.

The default mode for Roblox is Landscape Sensor although this can be changed on a per place basis with StarterGui.ScreenOrientation.

Locked Modes

Landscape left (the home button is to the left of the display):

LandscapeLeft.png

Landscape right (the home button is to the right of the display):

LandscapeRight.png

Portrait:

Portrait.png

Sensor modes

The two sensor modes that Roblox supports is Sensor and Sensor Landscape. In Sensor the device will detect when the device is rotated and try to maintain the most upright image possible (switching between portrait and landscape as needed).

LandscapeLeft.png Portrait.png LandscapeRight.png

In Sensor Landscape the device will detect when the device rotates and make sure that the image is always right-side-up in landscape.

LandscapeLeft.png LandscapeRight.png

Configuring Device Orientation

There are three properties that can be used to work with device orientation. These are:

  • StarterGui.ScreenOrientation
  • PlayerGui.ScreenOrientation
  • PlayerGui.CurrentScreenOrientation

StarterGui.ScreenOrientation

StarterGui/ScreenOrientation is used to set the default orientation for a place. When a player joins the game, it will use this property to determine the device’s starting orientation and the value of the property will be copied to the player’s PlayerGui.ScreenOrientation. Note that this setting will only make changes for new players joining the game. If a player is already in the game, changing this setting will not make any changes for that player.

This property can be one of the following:

  • Portrait
  • LandscapeLeft
  • LandscapeRight
  • Sensor
  • SensorLandscape (default)

PlayerGui.ScreenOrientation

PlayerGui/ScreenOrientation is used to set the orientation for a specific player’s device. When a player joins the game this property is automatically set by the value in StarterGui.ScreenOrientation. When this property is set the player’s client will immediately orient the viewport to match the setting. This setting can be useful when a game needs to give a specific player a particular experience, such as a trigger point on the map where a different view would be ideal or locking the view for a specific minigame.

This property can be one of the following:

  • Portrait
  • LandscapeLeft
  • LandscapeRight
  • Sensor
  • SensorLandscape

PlayerGui.CurrentScreenOrientation

PlayerGui/CurrentScreenOrientation is used to get the current orientation of a player’s device. This is useful as the sensor modes for PlayerGui.ScreenOrientation don’t say which mode the device is in, just what modes the device can be in.

This property always shows the actual orientation of the device and will only be one of the following:

  • Portrait

  • LandscapeLeft

  • LandscapeRight

Tags:
  • mobile
  • ux