Search code examples
unity-game-engineunityscript

playing an animation in landscape mode in unity


i am trying to play an animation in landscape mode in unity but as soon as the game start the phone turn in landscape mode and it quit without playing anything i have only one scene with a UI Image contain an animator and a simple animation this is the script of the image

AudioSource audio;

void Start () {
    Screen.orientation = ScreenOrientation.LandscapeLeft;
    audio = GetComponent<AudioSource> ();
    audio.Play ();
}

// Update is called once per frame
void Update () {

    if(!audio.isPlaying)
    {
        Application.LoadLevel("GameIntro");
    }
}

in player setting the default orientation is set to portrait if i comment this line Screen.orientation = ScreenOrientation.LandscapeLeft; my game work fine and the animation play in the default orientation mode but if this code is set it quite right after the game start what would it be the problem ? am I missing something ?


Solution

  • Using Animation Clips in Unity3D is not exactly Oriented Correctly even in Unity3d 5.

    You would have to manually Fix it's offset to the correct XYZ set.

    Meaning if you have Animated your GameObject <- on Landscape and the Your Orientation Changes. It will still Animate based on its own GameObject XYZ not on WorldScene XYZ.

    I hope this make sense to you. So to fix this problem. You can do 2 things.

    1. Manually Lock your Orientation and reset your Animation. easiest Not Recommended but not Ideal.

    2. Make your animation Correspond to WorldScene XYZ instead.