I am new to Godot Game Engine. Currently I followed a tutorial and created a little platform game with a player that can move around and jump.
I put my code to detect player input in the _physics_process function.
However, when I check for input for attacking and play the animation, the animation immediately stops, of course because on the next frame, it detects the player is idle, so I think I need some kind of flag that keeps the system informed the attack is being performed. I was thinking about timers, but… It starts to feel “off” because surely there must be a more simple and structured way to do this.
I currently followed Brackeys platformer tutorial, but it’s very basic and does not include a player that can attack, only jump and collect coins.
Consider using _unhandled_input for attacks. Polling in _physics_process is good for continuous inputs like movement where you want to check each frame whether the player is still holding down the button, but it can be cumbersome for discrete actions.