This is more of a general game development question. In the game I’m working on, I plan to have several breakable objects. Some of these will spawn one of several items when broken. I want it to work so that once the player breaks these objects and their respective loot items are created AND collected, that the breakable object will no longer spawn those collectible loot items again. This is to prevent the player from being able to farm items easily.
My first thought is that this would be done with a Global Variable structure, setting up the events so that when the object is broken and a global boolean variable associated with the collection of its contents is false, it will spawn whatever item. If that item is collected, you would set the global variable to true, never being set to false again regardless of whether the player changes scenes and comes back to the current scene.
However, with a lot of breakable objects in a game, this method feels like it could get messy with a lot of global variables to keep track of in the structure. But it’s the only way I can think of to make this work. Is there a “best practice” way of accomplishing these one-time collectibles from breakable objects? I’m open to any advice or tips at all to make this process as smooth as possible.
A second question as well, if I may. Using the same breakable object-item spawn example above, if instead you wanted the item to not spawn from the breakable object again for a set period of time (say, 5 minutes), what would be the best way to accomplish this with a timer? I assume I would use an object timer and appropriate object variables for the breakable object, but if the player breaks several breakable objects in the 5 minute example, are there then going to be several object timers running at the same time? If so, how would this affect the performance of a game?
Sorry for the long message, but I figured it was better to ask both questions here rather than creating two separate topics. Thanks in advance for any and all advice!!!