Conflicts in animations

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

I’m having the following conflicts in my code, when my player is stopped and jumps the “idle” animation remains and the “jump” is not executed.

And my other problem is, when my player ducks, the “down” animation is executed, but when the player shoots, the player enters the “idle_shot” animation and shoots in the stationary version and not in the crouched version.

and I still need to implement the “hit” animation where my player is hit by the enemy.
Note is that I am using AnimatedSprite

if is_on_floor():
	if Input.is_action_just_pressed("jump"):
		$jump_audio.play()
		motion.y = JUMP_FORCE
		is_jumping = true
		state = "jump"
	else:
		is_jumping = false
		if motion.x == 0:
			if Input.is_action_pressed("atirar") and state != "down":
				state = "idle_shot"
			elif Input.is_action_pressed("baixar"):
				state = "down"
			else:
				state = "idle"
		else:
			if Input.is_action_pressed("atirar"):
				state = "run_shot"
			else:
				state = "run"
else:
	is_jumping = false
	if motion.x != 0:
		if Input.is_action_pressed("atirar"):
			state = "jump_shot"
		else:
			state = "jump"
	else:
		if Input.is_action_just_pressed("jump"):
			$jump_audio.play()
			motion.y = JUMP_FORCE
			is_jumping = true
			state = "jump"
		elif Input.is_action_pressed("atirar"):
				state = "idle_shot"
		else:
			state = "idle"