Quick Time Event help

Hello, intemediateish level game maker here, and I'm having some trouble getting QTEs to work in my game. I'd like to have a simple directional input sort of mini-game, a bit like something like the player has to hit arrow keys in order to open a door, dodge a trap, leap over a pit, etc.

The instructions might be something like ↓ ↓ ↓ ← → and then I would like the player to hit those arrows on the keyboard/controller. I've looked around the forum and tried fiddling around without much luck, so I would really appreciate some input from the vets around here on how this could be done. Would be preferable if it could be done all in eventing.

Thank you all in advance! Have a nice day 🙂
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:
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:
  1. Stage - starts at 1, +1 each successful press; tracks which button in the sequence we're at.
  2. 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.)
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:
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:
  1. Stage - starts at 1, +1 each successful press; tracks which button in the sequence we're at.
  2. 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:
5fcd40bede39273bd3349dcc_image9.png

The green bar is way to the left.

Don't suppose you have any ideas?
Don't suppose you have any ideas?
Just make sure you're reading and understanding what the steps are doing, not just copying. 😉

In the tutorial, it used variable 24 for the "Goal Space Left," and you're using variable 14. But then on the next two lines, you're referencing variable 24 in your math.

You never set variable 24 to anything, so that's going to be treated as zero. Logically, you should be referencing 14.

Similarly, when setting "Goal Space Centre" you're referencing both variables 24 and 25, neither of which have you defined in this event.
Also, those script calls aren't really needed in this case, e.g.

◆Control Variables:#0014 Goal Space Left = Random 400..700 ◆Control Variables:#0015 Goal Space Right = Goal Space Left ◆Control Variables:#0015 Goal Space Right += 48 ◆Control Variables:#0016 Goal Space Centre = Goal Space Left ◆Control Variables:#0016 Goal Space Centre += Goal Space Right ◆Control Variables:#0016 Goal Space Centre /= 2
There are exceptions, but it's a good general rule to do things with event commands if you can. 👋
But I don't really understand it because I'm thick 🙁

I updated my variables to this:

◆Control Variables:#0021 QTE Pointer X = 436
◆Control Variables:#0022 QTE Pointer Y = 360
◆Control Variables:#0023 QTE Pointer Speed = 2
◆Control Variables:#0024 Goal Space Left = Random 400..700
◆Control Variables:#0025 Goal Space Right = $gameVariables.value(24) + 48
◆Control Variables:#0026 Goal Space Center = ($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 ({#0016},{#0012}), (100%,100%), 255, Normal
◆Show Picture:#3, Barpointer, Center ({#0011},{#0012}), (100%,100%), 255, Normal

And now the pointer is gone and the green one is way up in the top left corner. Don't suppose you have any idea where I'm going wrong? Apologies for my lack of skill and understanding...
Just make sure you're reading and understanding what the steps are doing, not just copying. 😉

In the tutorial, it used variable 24 for the "Goal Space Left," and you're using variable 14. But then on the next two lines, you're referencing variable 24 in your math.

You never set variable 24 to anything, so that's going to be treated as zero. Logically, you should be referencing 14.

Similarly, when setting "Goal Space Centre" you're referencing both variables 24 and 25, neither of which have you defined in this event.
You are still referencing variable IDs in your Show Picture commands which are different from the IDs you're using above.

It's like you're writing directions for someone and you're saying:
Put the scissors away in the drawer.
When you need to cut something, get the wildebeest out of the bureau.
Thank you so much! I've got it to work now. Yeah, I was just being silly and not checking the parameters properly. I have to confess that I found the tutorial a bit overwhelming, but your explanations really helped shore up my gaps in knowledge and misconceptions. Thanks again for taking the time to show me where I went wrong!

Original thread: https://forums.rpgmakerweb.com/threads/quick-time-event-help.161728/