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. Dismiss Notice

Input.acceleration

Discussion in 'Windows' started by musikit, Mar 12, 2014.

  1. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    Is this item different on windows store apps then on iOS and Android?

    When we ported from Android to iOS we never changed the Input.acceleration code at all. however on windows store (WinRT tablet) we seem to be getting wildly different values.
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
  3. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    Hello,

    Changing it to true didn't help so i peeked at it with the debugger and it is already true.

    EDIT: made a dummy project. it appears as your team's "if" statement is reversed. if i set it false it seems like i am getting values like i expected on iOS and Android.
     
    Last edited: Mar 12, 2014
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    In what way they are reversed? I mean, at what device orientation do you get incorrect readings?
     
  5. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    Win RT tablet (first model) portrait mode with the windows button on the bottom of the screen. I.E. "kickstand mode"

    i don't know how to explain this but i will try pseudo code

    bool flipAxis = false;
    if(deviceMode == KickstandMode)
    {
    flipAxis = true;
    }


    if(flipAxis)
    {
    float tmp = Input.acceleration.x;
    Input.acceleration = Input.acceleration.y;
    Input.acceleration = -tmp;
    }

    EDIT: tried to submit the project to the bug reporter but it errored out. how can i send a project to bugs@unity.com?

    EDIT2: uploaded project to google drive. put in email bug report. #596479
     
    Last edited: Mar 13, 2014
  6. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    Don't really want to harp on this however, i just ported our game to winphone 8 and it seems so far the acceleration values are similiar to ios and android. it does appear to be a winstore app bug.
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Can you make a repro case and submit a bug? This looks weird, with Input.compensateSensors it should return consistent values.
    Also, you mention tablet being portrait by design? I mean WinRT tablets I've seen are landscape by design, windows button is at the bottom when held in landscape mode.
     
  8. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    please review above. i have already submitted a bug report with example project.

    my mistake above. thought landscape... typed portrait. i do apologize. i am always holding my RT tablet in landscape mode. when in landscape mode. the kickstand and windows button are on the bottom of the device.

    the fact remains though that if i compare the Input.acceration values of a WinRT project to those of WinPhone, iOS, and Android they are not the same. the latter 3 are the same.

    to me it seems that
    iOS.Input.acceration.x = winStore.Input.acceration.y;
    iOS.Input.acceration.y = -winStore.Input.acceration.x;
    iOS.Input.acceration.z = winStore.Input.acceration.z;
     
  9. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
  10. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Thanks, will look into this.
     
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Had a quick look at this, findings are:
    - As you show in the picture, reading on WSA is expected to be different from WP and Android: device orientations differ. Tablet is in landscape, while other two devices are locked in portrait, but placed on their side. compensateSensors takes orientation into account. Try to put all three devices in portrait, as well as to lock tablet in portrait and place device on it's side like other two. Reading should match.

    - WP always device gives raw reading when in portrait orientation (like in your picture)

    - WSA device always gives raw reading when in landscape (lanscape-left in unity terms) orientation (like in your picture)

    - sensor compensations for WP are:
    portrait-up-side-down=(-x, -y, z)
    ladscape-left=(-y, x, z)
    landscaperight=(y, -x, z)

    -sensor compensations for WSA are:
    portrait=(y, -x, z)
    portrait-up-side-down=(-y, x, z)
    landscape-right=(-x, -y, z)

    - our testing for this is a cube in the center of the screen, which stays there while devide is flat on a table. Lifting any side of device makes cube fall to the down side, this should happen consistently regardless of device screen orientation, if compensateSensors is true.
     
  12. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    please check again readings do not match.

    both devices
    http://www.fileswap.com/dl/bJTIqyN1eY/
    WinRT
    http://www.fileswap.com/dl/5iIYBe5bf/
    WinPhone
    http://www.fileswap.com/dl/uAgKahLsYn/

    If you have a test project. please post it i'll download it and load it on my devices to prove to either me or you it works or doesn't

    EDIT: side note. just a documentation update but the docs for this function do not state anywhere that it is dependent on the project being in portrait or in landscape. the only "hint" we have is a comment in the example that states that the home button is on the right hand side. I'm assuming this is iOS since android doesn't have a home button. however that would mean to me that ALL devices regardless of the project being in landscape or potrait. if the device is held in landscape mode with the equivalent home button on the right then they all will receive the same value. that clearly is not the case here. so it seems at least the documentation needs an update to state that accerlation values are dependent on the project's landscape/portrait orientation and the location of the home button when in that orientation.
     
    Last edited: Mar 19, 2014
  13. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    That definitly looks like a bug.