Collectible moves to different location? *READ*

For a scavenger hunt mode in our horror game, we need to make it so that you have to find 5 items before you get caught. It’s a bit like in The Very Organized Thief (Another great Unity game) when the items you need to get move to a different spot in the area. How do we do this?

NOTE: We know HOW to MAKE the collectible, we just need to make it move to a different place each time you play the level.

Step #1: Create an array of spawn points. This could just be a public array of Vector3s that you initialize in the inspector. For something more visual, use small spheres to mark all the positions, give all the spheres the same tag, then use GameObject.FindGameObjectsWithTag() in start. Once found, cycle through and turn off the renderers so the spheres will not be visible when playing the game.

Step #2: Shuffle the array. You will find a number of posts on Unity Answers concerning shuffling the array. The typical solution is the Fisher–Yates shuffle algorithm.

Step #3: Assign the first ‘n’ positions to the objects.

For example, define 15 positions. Shuffle these positions and assign the first five to the five collectibles.