- Home /
Help with Android accelerometer
Hi there! I was programming a script to add force to a ball using the accelerometer of my Android tablet and I just got stuck. The problem I had is that the ball has only one point in which the "add force" is 0 (obviously hehe). But I'd like to set the add force to start adding it even if the tablet is a bit rotated. I don't know if It's a good explanation. What I want is to set the add force in a way that it does not apply any force in the x: -1, 1 and y:-1, 1 That way I will have a bigger area with no force and it wil be easier to stabilize the ball.
If there is any doubt just comment. I hope I can found out the solution. Thanks Albert
Answer by seejayjames · Apr 28, 2013 at 12:00 AM
If I'm understanding you right, you'd want a "buffer zone" around the "flat" accelerometer position. So, just choose a value (like 0.2) and only apply the accelerometer to the ball if either the X or Y accel data is bigger than 0.2.
You'll need to scale or offset the values so it adds the force gradually though (0.2 becomes 0.0, 0.3 becomes 0.1, etc. based on experimentation).
I'm working on it, any doubt I'll comment ;) Thanks seejayjames! Regards
Your answer
Follow this Question
Related Questions
Desperate for help on control for a ball on android phone. 1 Answer
Rigidbody only moving in one direction 2 Answers
Networking Accelerometer uses wrong axis 0 Answers
accelerometer speed 1 Answer
Player Movement when phone shakes 0 Answers