Ok guys, I understand how to make a basic input buffer.
Here is my 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>();
}
void AddKey(keys key)
{
InputPlayer.Add(key);
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)
{
SpecialsPlayer.Add(Special.Hadouken);
}
}
}
}
}
This works really well, but then I get repeated keys in the buffer when I keep a key pressed.
I could fix it by having a last keypressed variable and then only calling the inputbuffer.getkey if the key pressed is diferent. But this makes the buffer to behave rather stiff.
I would love to see how can I improve my code so It doesn't recognizes multiples keys when a button is kept pressed, but also allow for charge moves (Guile's sonic boom).
I also would love to see how input shortcuts works (using a previous special command as part of a second one, usually used in cancels to supers).
I would love to see what's the proper way to handle input buffers in kof and SF.