help with scripting combo

Hello all,

I am seeking help with developing a combo system. I have buttons in the game for the directions up, down, left, right, up left, up right, down left, and down right. I have boxes in the game which are obstacles, and there would be a combination on the boxes in order to break or destroy them so that the character can continue to move. so an example would be something like this:
Three boxes in the game.
The first box has a generated combo of 3 moves, which would be pressing the buttons [down, right, left].
The second box would have a combo of 2 moves [up, down].
The third box would have a combo of 5 moves [down, up left, down, right, left].

what I would like is that when the buttons are touched the combo would begin to have the boxes destroyed, but the boxes would not be destroyed unless the combo has been completed, and that every time a correct input is entered in the combo code for the box, a dust vxf prefab would be spawned.
An example for box 2 would be:
Player presses “up” button, the combo begins, and dust prefab is instantiated.
Player presses down button, combo is complete and box is destroyed.

I would also like for the combo to only begin once the first character has been entered correctly, and that it would follow the particular sequence until completion.

@mealone, check this out Random keys combo - Questions & Answers - Unity Discussions

I know this is a bit old, but to give you a direct answer:

Place this code on each box and set the dust and destruction prefabs.
The KeyCode array sequence contains the list of required key presses.

public Transform dustEffect;
public Transform destroyEffect;
KeyCode[] sequence = new KeyCode[3] {KeyCode.DownArrow, KeyCode.RightArrow, KeyCode.LeftArrow};
int current = 0;

void Update() {
    if (Input.GetKeyDown(sequence[current])) {
        Instantiate(dustEffect, transform.position, transform.rotation);
        current++;

        if (current == sequence.Length) {
            Instantiate(destroyEffect, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    } else {
        current = 0; //causes sequence to restart if wrong key is pressed.
    }
}

This will destroy all boxes that have the sequence, so if you only want one box active at a time, add:

bool isActive = false;

void Activate() {
    isActive = true;
}

and modify the first if statement to:

if (Input.GetKeyDown(sequence[current]) && isActive) {

Then just call .Activate() on each box when you want it to become active.

A simple function to randomly generate a key sequence is easy to write, or one to set from a master function.