UE4 Key-Sequences

Someone was having trouble with Key Sequences yesterday (e.g. Left, Right, Up, Left, Right, Fire) in UE4. Apparently the only method google could suggest was a highly complicated arrangement of branches that didn’t sound like much fun to implement and like a real pain to add to or change.

My suggestion is to use an Enum of possible key presses (Left, LeftDown, LeftUp etc.) and then store the last however many in an array which you compare to predefined ‘Make Array’ sequences of Enums, and once one matches execute whatever action you want for that sequence. Obviously you only add to the array if the key is different from the last entry in the array.

As you generally want the sequence to be either entered fairly rapidly or to not work, you could add a small timeout that is reset every time you press a different key. If the timeout reaches zero you clear the array ready to start again.

I hope this is some help.

lith

Leave a Reply

Your email address will not be published. Required fields are marked *