Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Building a 'Key Sequence' for the New Input System

Discussion in 'Input System' started by kevjnr147, Oct 4, 2020.

  1. kevjnr147

    kevjnr147

    Joined:
    Sep 27, 2020
    Posts:
    1
    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)

    Code (CSharp):
    1.  private void Update() {
    2.      if (Input.GetKeyDown(sequence[sequenceIndex])) {
    3.          if (++sequenceIndex == sequence.Length){
    4.               sequenceIndex = 0;
    5.               // sequence typed
    6.           }
    7.      } else if (Input.anyKeyDown) sequenceIndex = 0;
    8. }

    Cheers,

    Gaia
     
    nareshbishtasus likes this.
  2. shanecelis

    shanecelis

    Joined:
    Mar 26, 2014
    Posts:
    22
    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.
     
  3. Shivakuvira

    Shivakuvira

    Joined:
    Sep 26, 2022
    Posts:
    2

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