How Do I Accept Input and Functions Within A Delay?

I’ve created a very simple “Delay” macro (input with float for number of seconds, with the standard delay function) to be used in the level blueprint. What I’m trying to do is the following - have a block appear on screen for a fixed number of seconds (hence the delay), if the user presses spacebar within those number of seconds, have the block disappear. If the user doesn’t press the spacebar after those number of seconds, have the block disappear automatically. However, I can’t figure out how to get this if/else functionality to work within the framework of a delay. Maybe I don’t even need a delay, but I’m not sure how else to implement the timing.

You should use Timers, here as a quick something to get you started;

In Player Controller:

113140-playercontroller.png

In Your widget that displays the quick action:

Hope this helps! Mark as answer if did :slight_smile:

Hi Holybreath,

Thanks for your help. I’m a little confused about how this works (sorry, I’m pretty new to UE4 and want to learn). Let me be a little more specific about what I’m trying to do.

I’m creating a Go/No-Go task to (eventually) be used in a VR setting for use with an Oculus. For now, I’m trying to make a simpler version of it using keyboard input. In terms of the functionality and specific details:

  1. The cube that the subject will be reacting to should be invisible

  2. While loop with the following execution steps:

-Call a function that makes the cube visible and makes it either green (if the subject should go) or red (if the subject should not go). Simultaneously record the time that the cube appeared

-Keep the cube visible for 5 seconds. In that time, if the subject presses space, I want the call a function that changes the color to white and records the time that the subject pressed space. After 5 seconds, I want the cube to disappear again, whether or not the subject had pressed space

-Print a variety of things, including whether the round was a Go or a No-Go Round, if the subject pressed space, and if so, how long it took from the time the cube was visible until the time that they pressed space

-Increment the round variable (to make the data show that they are in the next round)

The part that I’m having trouble with is the bold step. Your answer most likely solves the problem, but I’m not really sure how to implement it within the current framework.

I doubt i will be able to fit the whole solution into 1 answer, sorry :frowning:

That’s not a problem. I don’t need a full solution. I just need help with the timer (the bold step)

-Keep the cube visible for 5 seconds. In that time, if the subject presses space, I want the call a function that changes the color to white and records the time that the subject pressed space. After 5 seconds, I want the cube to disappear again, whether or not the subject had pressed space