Hi, I’m creating a game where the world has nodes of resources such as plants, mushrooms, minerals, which grow overtime and go through several growing stages.
I thought about two solutions and I’d like to know which one is less resources consuming pls.
1- I use a single timer, every x seconds the script checks all the nodes; if a node is active (a node is active as long as the player is nearby), it starts a function which updates the stage of the node. My main concern about this solution is that the script will have to check several hundreds GameObjects every time the timer hits the magic number (maybe once every 5 mins or so).
The nodes would be children of a GameObject and I would use a foreach loop. Maybe I could easy the loop by changing the parent of the node when it becomes active, therefore I could loop through a shorter list of GameObjects.
2- Everynode has a timer and it works only when the node is active (as long as the player is nearby). This solution avoids to check all the nodes, though if the player is in a really populated area (a forest for example), there will be dozens of scripts and timers active (lets say max 50-70 nodes).
I think this solution is better because everynode will have its own timer, although I don’t know how heavy could be to have up to 50-70 active scripts/timers at the same time.
What do you guys think? Thanks ![]()