Building a 'Key Sequence' for the New Input System

Hi all,

I've been building a keysequnce for my game in relation to spell casting.
The current system uses the old Input system and the project setting recognises both at the minute.
This will be a problem when I introduce multiple players as their scripts will be listening for the same hard-coded inputs, and not independant of one another. I'm wondering how I would achieve similar functionality through the new input system as I'm honestly lost with it.

See here for my current implementation (stolen from another forum answer)

 private void Update() {
     if (Input.GetKeyDown(sequence[sequenceIndex])) {
         if (++sequenceIndex == sequence.Length){
              sequenceIndex = 0;
              // sequence typed
          }
     } else if (Input.anyKeyDown) sequenceIndex = 0;
}

Cheers,

Gaia

1 Like

Sorry for this being so late in response, but I just made this KeySequencer package that should satisfy your aim. Maybe it'll be useful to those that come after.

Hello sir, can you make a Chain Reaction game in unity. I’m beginner so i want reference