I was wondering how to destroy a certain amount of pickups when the game is started, based on how mant pickups I have collected.
For Exsample:
Lets say I have a scene with 100 pickups and I collect 50 of them, save and then exit the game. Then when start the game and press 'L' to load only 50 pickups should appear.
I already have a save system that stores the amount of pickups collected to a text file when I press the 'S' key and loads that information when I press the 'L' key.
Simple method would be to use a for loop to destroy a certain number of objects with the pickup tag. Or you could instantiate the pickups at run time unless you want them in a very specific place.
e.g.
var pickups : GameObject[] = GameObject.FindObjectsWithTag("pickups");
var numberToDestory : int = 10;
for(i=0;i<numberToDestroy;i++){
Destroy(pickups*);*
*}*
*```*
If you wanted to only spawn certain pick-ups on re-load, I would save the locations of those that are left. That way, when you re-load your scene, you spawn only the ones that the user didn't pick up.
To word it another way...
There is no need to Destroy anything in this case. Just save what the user hasn't collected, and Instantiate them in the same spots on re-load.