Key press to do two things, but one delayed

I am trying to learn about the Blender Game, using logic bricks only (for now). I want two things to happen when I press a key, one thing happens immediately, but I want the other thing to be delayed. For example, when I press a key, a text object might display “Key was pressed!”, but after two seconds, I want that same text object to display something different, maybe “Press a key when ready”. So I have an empty with a keyboard sensor, and a text object. So the keyboard sensor works and it sets the text as I want, and it also has a delay sensor to change the text. It sort of works, but I can’t figure out how to synchronize the start of the delay counter (i.e. reset the tics to zero) when the key is pressed. So what happens is I might get a two second delay before the text changes, but it may be less than two seconds, sometimes almost no delay, because the delay is always counting from 0 to 120 over and over whether a key is being pressed or not (I have “repeat” checked). So when I press a key, the delay tics might be anywhere, and that means I might get anything from zero delay up to 2 seconds (120 tics). How do I force it to start at 0 at the same instant that I press a key?

if property=0---------and-----------property=1
if keypress-------------/

if property min:1 max: EndLength-1--------and---------property add 1

if property= EndLength------------and---------property =0

of property = any frame or interval-------and---------do stuff

BluePrintRandom, what logic bricks are these? If this is Python, I don’t know it yet. Maybe in the future. I am only using the logic bricks for now.

Use the state system:
state_example.blend (451 KB)

logic

I’ll do a example as soon as I get a minute

BluePrintRandom, Thank you for helping

agoose77, of course your way works, but I can’t see how/where you are timing the change. It seems that you’re toggling the visibility of layers, but I can’t find any kind of delay time®. What am I missing now? Maybe I should just forget learning this. I wish I knew where you found out all the good information that you have shared! Thanks again.

It’s trial and error, and reading the docs.

The state system is a very basic FSM. Each object has 32 logic states that can be running. You can add, remove, toggle or switch between states.

When the key is pressed, I change to state two. When the state is entered, the Always sensor triggers the first add object actuator. The Delay sensor waits for X ticks after the state is entered and then triggers another state actuator that changes back to state one, and also adds the final text object.

I named the actuators incorrectly on state two, unfortunately, so their names aren’t useful for understanding which is which - look at the sensors driving them instead.