want punch animation to interrupt walk animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chris33556

i have this script for a beat-em up game. in the script i have the walk animation and after i have a punch animation.

so i want that when the player is walking he should be able to punch immediately after the walk. so effectively the punch anim should interupt the walk anim. however, the opposite is happening. the player has to stop first in order to punch. how do i fix this . here is the script:

the walk and punch are between line 13 - 34. any help would be appreciated thanks

:bust_in_silhouette: Reply From: Inces

so i want that when the player is walking he should be able to punch immediately after the walk. so effectively the punch anim should interupt the walk anim

This sentence is already contradicting. If it is supposed to happen AFTER the animation, it means it is not supposed to interrupt animation.

What You did in your code is : first check if player is moving, and only when he is not moving - check if it wants to attack. So naturally, attack can only happen when no movement input is pressed. If You want to cancel the animation, You don’t need this eliftower, just play animation on attack input, but don’t let attack be interrupted by walk, so invert it elif. If You want to attack after the one walk cycle is finished, You should use animation_set_next instead of play , it places animations in a queue.

However your code has deeper problem. When input is continually pressed your walking animation is stack on 1st frame, because You force to play it in process(). You will not be able to set up proper animation system like that. Learn about state machines and/or animation tree