Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Defualt phone orientation change?

Discussion in 'Scripting' started by ComputerBruce, Aug 10, 2015.

  1. ComputerBruce

    ComputerBruce

    Joined:
    Aug 6, 2015
    Posts:
    22
    Hi all

    I am using the accelerator to control my player on android phones.

    By default, the phone needs to be held vertically.

    Is there a quick and dirty way to make its default at 45 degree angle?

    Thanks for any help
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Could you post your code please, it would be easier to help, if we see, what have you got so far.
     
  3. ComputerBruce

    ComputerBruce

    Joined:
    Aug 6, 2015
    Posts:
    22
    Basically I am just addin 0.5 to the y input and it seems to work.

    Just wondering if that was the done thing.

    Code (csharp):
    1.  
    2. float curSpeed = Time.deltaTime * tiltSpeed;
    3.  
    4.  //tiltZ = Input.GetAxis ("Vertical") * curSpeed;
    5.  //tiltX = Input.GetAxis("Horizontal") * curSpeed * -1f;
    6.  
    7.  tiltZ = (Input.acceleration.z + 0.5f) * curSpeed * -1f;
    8.  tiltX = Input.acceleration.x * curSpeed * -1f;
    9. [/code