Android Accelerometer wiggling -
When I lean my mobile phone fast or left to move the player in my app, Time. How can I remove this effect and make it as smooth as it would jump into a doodle? I am using the raw accelerometer sensor event value to add player coordinates. Is there an algorithm or should I just use the sensor differently?
Public Zero {if (event.sensor.getType ()! = SENSOR) on Sensor Change (Sensor Event Event); Return; If (this.isRunning ()) {spieler.setMoveSpeed (-vent.values [0]); }}
You need to use a low pass filter, The problem you're experiencing from this will accelerate the accelerometer value
Example code:
float rawX = event.values [0]; Float rawY = event.values [1]; Flat rawjaj = event.values [2]; // Apply Low-Pass Filter mGravity [0] = Compass (Rawts, Mg. [0]); Marguerite [1] = Commass (raw, mg. [1]); Marguerite [2] = Compass: (Rawts, Mg. [2]);
For more information on checking a short pass filter
Comments
Post a Comment