So I’m currently working on a hide and seek-esque game and am making it so the every time you play it’s hidden in a different spot. The way I went about this was to hide multiple objects and give them the same tag, then to put them all in an array and delete all but one of them. How would you recommend I go about randomly selecting one object in an array and destroying all the others?
To do what your asking, literally:
Well it’s simple you must only pick a random element from the full array, preferably using the ‘Remove’ method which returns to you the element which you are removing. Then you keep that element somewhere else for usage. This will give an array with all but that one object.
To actually accomplish what you’re trying to do in a simpler manner:
Why don’t you simply start with all objects deactivated (‘SetActive(false)’) then pick a random one and activate just that one? [Deactivate it later when no longer using it, of course]