# Accelerometer problems

1. When I hit an object, my Fighter is supposed to fall to the Ground but because of the Accelerometer, I can still move it up and down even though it died. The Scroller on the x-Axis though stops.
Question: (FIXED) How can I make the Accelerometer stop, after I've been hit, and make the Fighter accelerate to the ground (in absence of the accelerometer, all by itself)?

2. When I move the Fighter up and down, the transition from "moving up" to "moving down" isn't smooth. It seems like it lags.
Question: How can I Increase the Sensitivity of my Accelerometer?

3. Also, when I tilt the phone further, the velocity stays the same.
Question: How can I increase the velocity, in relation to the tilt degree?

The code is below:

Accelerometer Code:

float accelY = Gdx.input.getAccelerometerY();

if (Gdx.input.getAccelerometerY() < 5){
velocity.y = -40;
}

if (Gdx.input.getAccelerometerY() > 5){
velocity.y = 40;
}


When Fighter hits an Object and dies:

public void die() {
isAlive = false;
velocity.y = 0;
acceleration.y = 460;
}


For 2 and 3 I would try to multiply like so:

Scaling = 1.2f;

If(Gdx.input.getAcceleratorY() < 5){
Velocity.y = (Gdx.input.getAcceleratorY()*scaling)*(-1);
}else if(Gdx.input.getAcceleratorY() >= 5)
Velocity.y = Gdx.input.getAcceleratorY()*scaling;
}


Try different values for scaling (probably has to be greater than 1). This should result in a more sensible, smoother and faster moving of your fighter.

Check if the player is alive before applying the input.

  float accelY = Gdx.input.getAccelerometerY();

if(isAlive) {
if (Gdx.input.getAccelerometerY() < 5){
velocity.y = -40;
}
if (Gdx.input.getAccelerometerY() > 5){
velocity.y = 40;
}
}


Why do you update the velocity of your fighter directly from the accelerometer? You should instead update its acceleration. By doing this, the movements will be smooth.

This is also the reason why the velocity stays the same if you tilt the phone further: you are always setting the velocity to + or - 40.