How to make an Input Buffer?

I'm trying to make an Input Buffer in Unity C# for later projects, and I've only found this old post from 7 years ago — here is the code:

public class InputBuffer : MonoBehaviour {

public int max_buffer;
public enum keys { down, up, left, right, X, Y, Z, A, B, C }
public List<keys> InputPlayer;
public enum Special { WPunch, MPunch, SPunch, WKick, MKick, SKick, Hadouken, Shoryuken }
public List<Special> SpecialsPlayer;

void Start () {
InputPlayer = new List<keys>();
SpecialsPlayer = new List<Special>();
}

{

if (InputPlayer.Count > max_buffer)
{
InputPlayer.RemoveAt(0);
}
}

void CheckSpecial()
{
if (InputPlayer[InputPlayer.Count-1] == keys.A)
{
if (InputPlayer[InputPlayer.Count-2] == keys.right)
{
if (InputPlayer[InputPlayer.Count-3] == keys.down)
{
}
}
}
}
}


The problem is I can't get it to work. There are no errors or warnings, and I can't Debug.Log the inputs.

Should I make an input script that references this buffer, or is there a way to make it work?

• Where in your code do you call AddKey() with the newly pressed key? You say you can't Debug.Log the inputs — why not? What is stopping you? May 25 at 11:40
• The Debug.Log doesn't appear on the console, and what method should hold it in this case? also I should clarify that this code isn't mine, I reposted it here in hope that someone can help me make understand it and configure it. May 25 at 11:59
• It sounds like you don't understand what this code does. This code does not listen for input. You need to write your own code that listens for input, then adds it to the buffer by calling AddKey(). Then you need to check for a special combination by calling CheckSpecial(). May 25 at 12:07