iPhone Horizontal Orientation Switches to Vertical

During gameplay in horizontal mode and tilting the device to move an object, every once in a while, it looks like the screen wants to shift to a vertical orientation, but doesn’t. You can see the typical black frame start to appear along the edges just for a second (like when you adjust the iphone’s volume while switching orientation).

The Player Settings Default Screen Orientation is set to: Landscape Left

Is there something I can put in the code to ensure it’s locked in horizontal orientation throughout the level?

Here’s a sample of the code I’m using for tilt:

if (iPhoneInput.acceleration.x > -.56 iPhoneInput.acceleration.y < .15 iPhoneInput.acceleration.y > -.15) {
ball.AddRelativeForce(Vector3(0,0,10) * powerMultiple);
Direction = “Forward”;
}

That’s the keyboard autorotating whenever it detects an orientation change. You can get rid of the black rotating outline if you put in some code to tell it to not do that.

You can just put this code in your initial scene and it should stick for the duration that the app is active:

function Start() {
   iPhoneKeyboard.autorotateToPortrait = false;
   iPhoneKeyboard.autorotateToPortraitUpsideDown = false;
   iPhoneKeyboard.autorotateToLandscapeRight = false;
   iPhoneKeyboard.autorotateToLandscapeLeft = false;
   }

Works great. Thanks!

This post should be more widely known. It took a lot of work to find it, and yet the simple solution is exactly what I was looking for. Thanks!

Agreed with Pmunsey, this topic should be almost sticked. And the problem has been solved for me too, thanks a lot!