Download

Storing Variable values over n period of time and averaging them?

Hello,

I have input from an external device in which the values are stored in variables in the engine.

These values update every game tick.

I would like to be able to store the values for n amount of time and then average the values out into a new variable is this possible?

So it would essentially keep a buffer of the values for lets say 5 seconds then it would take an average of them.

This should be fairly easy to do. Each time a new value is added increase a seperate counter variable. Check if that variable is > MaxSample amount and if true use a branch to divide the value by count then clear the count and the running total. Something like this should work… I have not tested it :slight_smile: