Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

879448 Posts in 32980 Topics- by 24365 Members - Latest Member: Mimiga

May 24, 2013, 05:50:02 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Handling Accelerometer Input
Pages: [1]
Print
Author Topic: Handling Accelerometer Input  (Read 293 times)
FTLRalph
Level 0
***


Professional Crastinator


View Profile WWW Email
« on: April 14, 2012, 07:14:17 AM »

Hey guys.

I have a question regarding accelerometer input (on Android devices, at least, but I'm sure the issue is the same on all devices).

I'm trying to develop a game in which the accelerometer moves the main character (tilt forward/back to move forward/back, rotate to turn, etc).

However, I realized that this may not be as easy as just taking the accelerometer input on the _ axis and doing some math with it.  I have to take into effect the user's orientation (sitting, standing, lying on their back / stomach, etc).  In all of these cases, there's the problem of the program not knowing if the user is tilting the phone to move the player of if that's just because of how they're resting / holding the phone.

I was wondering if there is a common way to get around this issue (maybe by somehow taking into effect all of the accelerometer's axis values in order to determine the user's "resting" orientation?).

I'm not really sure and I appreciate any help, thanks!
Logged

http://ForTheLoss.org - Tons of nonsense, really.
Xienen
Level 2
**


Greater Good Games


View Profile WWW Email
« Reply #1 on: April 14, 2012, 09:00:50 PM »

...maybe by somehow taking into effect all of the accelerometer's axis values in order to determine the user's "resting" orientation? ...

I don't have any experience in this area, but that would be my suggestion.  Whenever a level starts, you can take that as the resting orientation.  Perhaps, also, if a player pauses and resumes the game, you take another "resting reading".  This could be good for 2 reasons, first being that players will probably pause before changing their position or they may put the game down for a while and come back to it.  The other reason is that it allows the player to reorient the game, should it get out-of-whack in their opinion.
Logged

Owner/Programmer at Greater Good Games makers of Break Blocks
Currently developing It Hungers(Unity) and Swipe Attack(UDK)
Ludophonic
Level 1
*


View Profile
« Reply #2 on: April 14, 2012, 09:50:49 PM »

It partly depends on the axis you're trying to get.

Imagine someone standing holding their phone upright. Edge down, screen facing them. If they rotate the phone left or right the x-axis will rise or fall as they rotate around the z-axis. And the x-axis will point straight sideways when at centre.

Now imagine someone sitting and holding their phone more in their lap, screen facing towards the sky. If they tilt the phone left or right, the x-axis will rise or fall as they rotate around the y-axis. And like above the x-axis will point straight sideways when at centre.

This is great! This means that no calibration is required for this particular tilt. Now if you want to add tilt forward/back... that's when you start to have a problem. I think you're best off if you can design around the need for calibration. But if you can't consider trying to design as many inputs as you can to not require it.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic