You need to use code tags Using code tags properly
couple things about your code,
-
when you say “bpm.ToString()”(at the end of the if statement) without any context like “clickRatePM.text = bpm.ToString()”(below the if statement) it doesn’t do anything, .ToString returns a string representation of the bpm float value and you’re not doing anything with it (assign it to something) so it should not be there - i’m sure your IDE and the unity console warns you about that.
-
why is the assignment “clickRatePM.text = bpm.ToString()” outside of the if statement? no reason to set its value if the value hasn’t changed - you’re just doing extra work, and while that might not matter in such cases it’s bad practice.
if you want an average over time you can go about it in many ways, you just need to keep track of what happened in the past.
my first instinct is to keep a collection that holds the bpm value for each previous second and calculate by that, but i’m sure there are way better ways to go about that - look at tutorials that do rhythm games, you got a lot of overlap there.