- Home /
How to implement "pattern selection" in Unity?
I am trying to make a therapy game. Here's how the game is supposed to work:
I have an array of objects. There is a script that randomly selects an object from the array If the player selects the same object as the one selected by the random function, then score increments by one, else it goes down, and the cycle repeats with the script choosing a random object again. I have implemented it so far.
However, I want to expand the functionality of the game. I want to add a "pattern selection" to the game, wherein the randomly selected objects are added to a Queue, and the player has to select all the objects in the queue in the correct order before the script that chooses random object is invoked. If the player selects all the objects in the queue in the correct order, the score goes up, but if they mess up the score goes down and another random object is selected and added to the queue.
Here's an example: Let's say I have 4 different objects in an array named a, b, c and d.
- In the first iteration, the script selects b at random. Objects in queue: b
- The player selects b and score goes up (because there's only one object in the queue)
- In next iteration, the script selects d at random. Objects in queue: b, d
- The player has to select b AND d, in that order, and score increments and so on...
I can't seem to implement this functionality, however. I am not very good at programming, and while I'm aware that this sort of pattern selection has a name, I can't find anything on Google. I don't even know if using Queue for this is the best option. Any help to implement it would be really appreciated!