Attack animation with timers or other method?

Godot Version

4.3

Question

Hello,

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.

Thanks in advance!

Use the animation finished signal.

Although I would ultimately setup a animation tree to do all the heavy lifting.

Also animations can call functions and change properties.

To say the least do not need to use a timer.

1 Like

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.

1 Like

Allright thanks for the replies. I will look for tutorials and docs on animation trees to create a structured setup.

Also thanks for the tips for the _unhandled_input function.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.