The event of pressing the button in the scene does not work the first time

I have a widget call when the “1” key is pressed, but the widget is called only on the second button press. When you first click in the game, nothing happens.

After I call the widget and close it, subsequent calls will work the first time. What could be the problem?

What is the default value of the Pause variable? Also, it may be easier to just use a FlipFlop node in this case.

Can you tell me more about FlipFlop?

the default pause variable says that the game should not be paused

If the Pause variable is false by default, then your Branch node will begin by trying to un-pause instead of pause.

The FlipFlop macro will flip (hence the name) between output A and output B every time it is executed. In your scenario, you could just remove the “Pause” variable and replace your Branch node with a FlipFlop node.

1 Like