M
If you're working with only directional keys, you could do this by temporarily boxing the player in with invisible, Same as characters map events. Set each event to Player Touch trigger. Then when the player tries to move left, they'll trigger the event on the left, etc. You could show which button(s) are expected using pictures or additional map events. That saves you from making an input-loop type event.
Otherwise this tutorial might be helpful:
by: @hiddenone Read the Tutorial Here!
forums.rpgmakerweb.com
I personally prefer to work with pictures like in the tutorial. In your case, I'd consider setting up a standard input-check loop, then have a couple of variables:
- Stage - starts at 1, +1 each successful press; tracks which button in the sequence we're at.
- Time - starts at e.g. 300, -1 per loop: if it hits 0, player fails.
Could also reset "stage" on an incorrect input to combat mashing, but let's focus on getting the basics working first!
The event structure might look something like this (there are various ways to organise it):
Spoiler: example structure
Show Pictures (e.g. 1~5) representing button sequence
Stage = 1
Time = 300
Loop
Comment: Check for valid input.
If Stage = 5
If Button [->] is triggered
Stage += 1
Else
Comment: If different input is triggered, set Stage = 1
End
End
If Stage = 4
If Button [<-] is triggered
Stage += 1
Else
Comment: If different input is triggered, set Stage = 1
End
End
...ditto for stage 3, 2, 1...
Comment: Check for end of sequence or timeout.
If Stage > 5
Break Loop
Else
If Time <= 0
Break Loop
End
End
Comment: Update button picture(s) to match Stage variable.
Comment: Update timer and wait for next frame
Time -= 1
Wait 1 frame
End Loop
Erase Pictures of button inputs
If Time > 0
Show Text: Success with \v[Time] frames to spare!
Else
Show Text: Time's up!
End
There are various options for displaying intended input, e.g. a single picture that updates each time, or a pointer/box picture indicating one of a sequence of button pictures.
For checking an arbitrary button trigger (i.e. pressed this frame, but not last frame), you could try
Conditional Branch -> Script:
JavaScript:
Input._pressedTime === 0 && Input._latestButton
Alternatively you could restructure the event so that you check each valid button input (e.g. down, left, right, up), then reset if it's not an appropriate Stage for that input. As opposed to my example, which checks Stage first, then button.
(Technical note:
Input._latestButton is not a reliable check for "is
pressed" because it only tracks the most recently-
triggered button. Multiple buttons can be held at once, so the most recent trigger might have been released while an earlier button is still being held.)
Hey, thank you so much for taking the time to help! May I ask for some help regarding the tutorial you kindly linked? I tried to follow it, but I seem to have done something wrong, and I can't figure it out.
This my event. (Screen width is 1280, Screen height is 720)
◆Control Variables:#0011 QTE Pointer X = 436
◆Control Variables:#0012 QTE Pointer Y = 360
◆Control Variables:#0013 QTE Pointer Speed = 2
◆Control Variables:#0014 Goal Space Left = Random 400..700
◆Control Variables:#0015 Goal Space Right = $gameVariables.value(24) + 48
◆Control Variables:#0016 Goal Space Centre = ($gameVariables.value(24) + $gameVariables.value(25)) / 2
◆Control Switches:#0024 QTE Moving Right? = ON
◆Tint Screen:(-68,-68,-68,0), 60 frames (Wait)
◆Show Picture:#1, barbackground, Center (640,360), (100%,100%), 255, Normal
◆Show Picture:#2, Bargoal, Center ({Goal Space Centre},{QTE Pointer Y}), (100%,100%), 255, Normal
◆Show Picture:#3, Barpointer, Center ({QTE Pointer X},{QTE Pointer Y}), (100%,100%), 255, Normal
◆Text:None, None, Window, Bottom
: :Press 'OK' when the pointer is in the green goal!
But instead of looking like this:
The green bar is way to the left.
Don't suppose you have any ideas?