Question by
hArtdirector · Jul 27, 2017 at 10:04 PM ·
c#arraylistaverage
Array with pushing values?
Hello there, I have a FLOAT called "p" and it changes in every single update. Now i wanted to store like the last 100 values of it. So basically the oldest one always gets overwritten by the newest one in a predefined range of 100 values.
In the next step i want to return the average of those 100 values, but that should not be the problem.
So how would i store that values ? Ive read Lists in unity would be an alternative to arrays here, but i have no i idea how to do that push-operation. Im using c# and unity 5.6.
Comment
Do you want to start with an empty array/list with a max capacity of 100, and wait until it fills completely before you start overwriting old values and getting the average?