Filter/smooth a variable
Hello,
Newbie here. I receive input from a potentiometer (from Arduino). I then use this variable to change my slider value. The problem I am having is variable is noisy - I wish to smooth the data. I believe a simple moving average "filter" will do this trick - but I don't know how to implement this on Unity.
Something like this:
ys(1) = y(1)
ys(2) = (y(1)+y(2)+y(3))/3
ys(3) = (y(1)+y(2)+y(3)+y(4)+y(5))/5
ys(4) = (y(2)+y(3)+y(4)+y(5)+y(6))/5
currently in my void update I read the poteniometer and call the following function
private void MoveCube(float horizantal, float vertical) {
slider.value = (float) horizantal;
}
Thank you and all the best
Your answer
Follow this Question
Related Questions
How to smoothly change position 1 Answer
Smooth 360 degree rotation every keypress - C# 0 Answers
How to move an object "Smoothly" away from another object? 0 Answers
Make a Point Light hit only the front side of objects 0 Answers
moving the camera smoothly to players current position in unity 2 Answers