Search Unity

simple combo system

Discussion in 'Editor & General Support' started by jackcbrown02, Sep 8, 2021.

  1. jackcbrown02

    jackcbrown02

    Joined:
    Mar 8, 2020
    Posts:
    2
    I am trying to create a simple script that, after the user presses j three times and l (lover case L) once, an animation is played. How would I do this?

    EDIT: I am a complete novice to coding, so please do not comment something like "oh, just create an array here, and...". Instead, perhaps you could provide me with some sample code.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,726
    That would essentially be writing your script FOR you, which is not what the point of this is for.

    I suggest you invest some time in learning how to code in Unity. See below for some great starting points.

    If you want to try it with what you know now, try this approach:

    Put the keystrokes in a public inspector array (so you can easily change it)

    logic:

    - start index at 0

    - accept keypress:
    - compare it to the indexed key in the array
    --> if correct, advance to the next index
    -----> if index greater than array length, play animation
    --> if wrong, return index to 0

    That's it. If you cannot code that, there's no point in someone here writing it for you. They might as well work on their own game.

    Here are some great tutorials.

    Imphenzia / imphenzia - super-basic Unity tutorial:



    Jason Weimann:



    Brackeys super-basic Unity Tutorial series:



    Sebastian Lague Intro to Game Development with Unity and C#: