Smooth Accelerometer movement
Does anyone have a suggestion for smoothing out accelerometer movement.
I am controlling a car and can get it to move up, down , left and right, fine, but it is a bit jerky. I am using move control with stacked on. Any good ideas for moving diagonally ?
I am controlling a car and can get it to move up, down , left and right, fine, but it is a bit jerky. I am using move control with stacked on. Any good ideas for moving diagonally ?
Comments
Smooth the accelerometer movement by averaging the input of an axis.
Example:
If we want to smooth the y-axis, we do the following:
1. Create some variables or in GameSalad's case, Attributes. In an actor create the following (Real) attributes:
AccelSmooth1
AccelSmooth2
AccelSmooth3
AccelSmooth4
AccelSmooth5
AccelSmoothFinal
2. Now in the same actor, create a group called "Acceleromter Smooth Group" to keep things organized. Within that group, drag in a constrain attribute behavior and set it as follows:
Constrain Attribute: self.AccelSmooth1 to game.Accelerometer.Y
Note: game.Accleromter.Y is located in Devices > Accelerometer.
3. Drag in a timer behavior into the group and set it for .03 seconds. Now drag a constrain attribute behavior into the timer you just created and set it as follows:
Constrain Attribute: self.AccelSmooth2 to game.Accelerometer.Y
4. We need to repeat step three for self.AccelSmooth3, 4, and 5 as follows:
timer: .06
Constrain Attribute: self.AccelSmooth3 to game.Accelerometer.Y
timer: .09
Constrain Attribute: self.AccelSmooth4 to game.Accelerometer.Y
timer: .12
Constrain Attribute: self.AccelSmooth5 to game.Accelerometer.Y
5. Ok, AccelSmooth1, 2, 3, 4, 5 attributes should be set at this point. Drag in Constrain Attribute into the group and set as follows:
Constrain Attribute: self.AccelSmoothFinal to (self.AccelSmooth1 + self.AccelSmooth2 + self.AccelSmooth3 + self.AccelSmooth4 + self.AccelSmooth5)/5
6. And your done. Use the AccelSmoothFinal attribute in place of game.Accelerometer.Y to give you a smooth y-axis input.
Breakdown: You added a real time accelerometer reading + 4 other readings at .03 second intervals up to .12 seconds for a total of 5 different readings and divided them by 5. Pretty simple right?
This may not be the optimal configuration and therefore you may want to play with the time and the amount of readings to maximize smoothness.
edit: just read the rest of your post...how many constrains and timers is that in total then...!
edit2: X axis ?
edit3: I'll give it a try
I know, a bit much - 4 timers, 6 constraints. I'm sure reducing to 3 readings would be just about the same.
Both the X and Z axis would be the same. Just replace game.Accelerometer.Y with X or Z.