I have Solar Panel Prefabs that contains a script to output varying amounts of watts every 1 second it chooses a random number (watts). Id like to have a Text UI shows the Realtime total watt output of all the prefab solar panels in my scene. Just as a real Solar System watt meter will show with the varying sun conditions.
My Issue is how to do this in script?
I have a central script with a Public Static float variable that all the Solar Panel Prefabs add there watt outputs into. But of course this wont work for what I want, as it will just keep adding up all the watts into a big number that keeps growing.
I need a real-time watt readings which would update every second to show the current total watts, so varying up and down. Would a list be a solution? and how to go about this, still new and learning.
Thanks for your reply. I’m trying to get my head around it still. Still learning. So it should be a struct instead of a class for this? It makes sense to calculate all the entries in the list then delete them every second and do it again. (so they don’t keep accumulating creating a growing number.
As the solar watt output is determined by a random number that changes also at random times. Its complicated things for me.
Would I be storing GameObjects in the list? In my solar prefab, I would have it add itself to a public static list when the solar prefab is instantiated. But then im not sure how to access the float value within each prefab when it comes to Suming up the total.