hello I have a problem where player fires a bullet right at the beginning of the scene whenever the scene is started upon players death? this only happens when the scene is reset and when firing using the controller A button instead of the Z key?
example using A button
I would probably not be using timers in the way you are, but that’s tertiary to the issue.
The human body is not faster than a computer. Since the scene restarts in a single frame (0.016 seconds), the button is still being held when the scene begins, and the engine processes the events while that happens.
What you should look into is toggle variables for your action buttons. Basically, a variable that tracks ‘has this button/key been released since last pressed?’ as a global variable, and make it required as a condition for your actions.
It’s a bit complex, but you can look at the Not-A-Vania example, especially the finite state machine transitions from Idle to Jumping, to see a use case for something like this.
thanks that fixed the problem added global variable = 1 on press. global variable = 1 on released then added global variable = 0 when player is dead.
i would have done it with a boolean, but that works too. that solution worked for me as well