Great question 
A very simple approach to smooth out a noisy y variable would be to replace something like this:
// make x equal y NOW
x = y; // x is as noisy as y
with this
// move x 9% towards y
x = lerp(x, y, 0.09); // x is less noisy than y
so even if y is jumping up and down, x will slowly drift towards y. One issue of this approach is that it adds some latency, so x follows y after some frames or seconds depending on how small the third parameter is. Latency and smoothing increases as that third parameter decreases.
If you need a better smoothing formula you could use this library instead:
Unrelated tips:
- Please donโt delete things you have written before in the forum because it makes the thread harder to read. Think that when you ask a question is not only for you, but for everyone to learn from, so itโs useful to see how you improved your question above
- You can format your code in the forum nicely with syntax highlighting by editing your post, selecting the code, and pressing the
</>button in the post editor.
Welcome to the new forum! 