Search Unity

Question Does Gyro sensor require more battery consumption on mobile devices?

Discussion in 'Input System' started by enghqii, Nov 18, 2022.

  1. enghqii

    enghqii

    Joined:
    Sep 4, 2015
    Posts:
    5
    Hi

    As a subtle gimmick, I want to rotate the camera direction just slightly along with the device's orientation on mobile platforms.

    In the first place, I was going to implement this with the gyro sensor (Input.Gyro), but I kinda recalled that someone said that Gyro sensors on the phone eat a lot of battery, so it's much better to use just the accelerometer sensor if the feature you're gonna make isn't that significant. (Honestly, I can't even remember where/when I heard this tho)

    Can someone clear this out for me? that using the gyroscope sensor input eats more power on mobile devices. or not? or negligible?

    Thank you so much for your attention.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,989
    Based on this image I'd say the difference is totally negligible, more so the lower the update frequency (for that gimmick you can probably sample at 10 Hz to get the desired effect):
    Battery-consumption-per-active-sensor-and-sampling-condition.png

    The more interesting issue is that this gimmick requires you to calibrate the device. Do you really want to add UI just to support this gimmick?

    What I mean by this: if the phone is lying flat on the table (facing Y up) as the game is launched, the game would probably consider this to be the default sensor position (device orientation/facing) on which to base off the relative camera rotation. Now the user picks up the phone, holding it straight in front of it (facing Z forward) in order to start playing. Now your camera rotation offset will always have the camera point downwards while it may swing left/right pretty quickly and/or it may even swing in the opposite direction.

    For something like that you have to calibrate the device position and possibly tell the player to keep holding the phone in that orientation while playing or force/offer a recalibration when the user changes position, ie from sitting, playing in lap towards laying on back, holding phone up in front of face.

    Unless you frequently recalibrate internally ... possibly taking the average of the last 100 measurements or so and use that as the current facing of the device. This needs to be balanced so it doesn't feel like an autocentering screenshake gimmick (that users might want to turn off because it's annoying or gives them nauseau / makes them feel sea-sick) but isn't too slow so that when a user changes position drastically it won't cause the camera to be off to one direction for several seconds (huh, is this a bug or what?). You may need to add more code just to detect large changes in orientation to make this process faster.

    Maybe there are ready-made solutions for this that I don't know of, like a built-in support in the mobile SDKs for exactly this kind of thing. Haven't been doing mobile dev for several years.
     
    Last edited: Nov 18, 2022
  3. enghqii

    enghqii

    Joined:
    Sep 4, 2015
    Posts:
    5
    Awesome. thanks a lot for the graph and the following citation via the image link.

    After quick prototyping, we decided that we won't be needing recalibration. (A scene change will most likely happen before the gyro sends the camera too far away) It's gonna add a very subtle amount of angles for each axis. And most importantly, it doesn't affect the game's mechanics and could be easily off in the settings.