How to check for input sequences/ sequential inputs and distinguish from single inputs?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ZachMoldof

Hi, I’m making a 2d bit art skateboard game. I’m new to Godot, and new to coding.

I’m trying to figure out how to set up my inputs so that I can check for sequences as well as individual inputs.

My input is set up like an 8 bit NES controller. Up, Down, Left, Right, B, and A. The directional pad navigates the player, and the buttons control the feet. Pressing different sequences with the buttons and the directional pad triggers the tricks.

I understand the basics of creating actions in the project settings, and assigning those actions to inputs in code. But I don’t understand how to create an input from more than one button press.

Any help is appreciated.

:bust_in_silhouette: Reply From: hilfazer

I made a basic, unoptimized implementation of such a system, it’s on github:

Tested in godot 3.1 alpha3.

SequenceDetector.tscn is doing actual job, its usage is shown in Control.tscn.

It emits ‘sequenceDetected’ signal with integer argument when sequence is detected.

It works on input actions since they are flexible.
By default is consumes input action that appear in action sequences. It can be turned off to let InputEvents pass through.

Thanks so much! If I use it in my game, how should I credit you?

ZachMoldof | 2018-12-20 14:49

There’s no need to credit me but you can use my github nickname, if this is what you’re asking.

hilfazer | 2018-12-20 15:49

Got it, will do. I’ll give you a shoutout in the game somewhere. Maybe Hilfazer’s pizza or something…

ZachMoldof | 2018-12-20 16:14