GMS 2 [SOLVED] keyboard_lastkey issues

C

ChrisMG12

Guest
I'm following the tutorial from rm2kdev on fighting game input
and everything was going pretty well until I decide to just try the Hadoken combination(DRp, p is a light punch).
However, when I tried it, the input_chain comes as either RRp, or if I do it very fast it will come as ppp.
I'm guessing this is because of keyboard_lastkey registering the latest key if 2 or more buttons are pressed at the same time, but I'm not sure.
Is there any way I can I can fix it, or is there any mistake I made from inaccurately copying from the video?
Any help is appreciated like simpler fixes or other threads talking about this.
Thanks
 
C

ChrisMG12

Guest
IK its DdrRp(dr is down-right), but i wanted a more simpler version so I chose this.
 
C

ChrisMG12

Guest
If it is possible can we implement something like dr(down-right), I tried case 40 && xx: but that didn't work.
 
E

Engineer

Guest
Haven't seen the video, but the task is not as trivial as it first seems.

I'd be using keyboard_check() as you will be able to use && for your multiple key combos (eg, down and left), you can't check for && on lastkey as that is only a single key value.

Valid inputs will then look like "RRRRRRRDDDDDLLLL" for a RDL combo, which is what you are experiencing.

You just need to make sure that the change between RDL happens within a certain duration to make the combo valid.

If the change in RDL happens in say half a second, combo achieved. If not, it is invalid.

Also need to invalidate the combo if a wrong sequence pops in there somewhere, eg RDRL.

Hopefully, I haven't explained this too confusingly, I am on an iPad and off to bed. So this post is a little rushed. :)
 

TheouAegis

Member
Inputs were stored in one variable for fighting games. 0 is no input, 1 is R, 2 is L, 3 is invalid so 0 (LR), 4 is D, 5 is DR, 6 is DL, 7 is invalid so D (DLR), 8 is U, 9 is UR, 10 is UL, 11 is invalid so U (ULR), 12 is invalid so 0 (UD), 13 is invalid so R (UDR), 14 is invalid so L (UDL), and 15 is invalid so 0 (UDLR).

So the combo is [4, 5+flipped,1] and the punch button is essentially the finalizer, so not really part of the combo unless you wanted to force the final combo to be something like 129+flipped (meaning the final direction MUST be still held when punch is pressed).

I think the trickiest bits are timing.
 
C

ChrisMG12

Guest
Thanks for your suggestions. Engineer, thanks for helping me find the answer, I ditched the (38-UP, etc) thing and just mapped out each key and did it in the step event instead of the key up event replacing (switch last_key : case .....) with (if keyboard_check_pressed) and it worked like magic. TheouAegis thanks for the variables tip, but I can't implement it cause I will get too confused too easily but will probably implement it in another project, but still thanks.
 
Top