My animation is bugging

Godot Version

4.2.1

Question

I have a bunch of animations on my character working well but when I try to crouch and shoot at one he is bugging. I have animation for crouching and animation for shooting in crouch but for some reason this animation isn’t workig.

Here is my (broblematic part I guess) code:

	elif Input.is_action_just_pressed("main_action") and shooting_timer == true:

		if is_crouching == false:
			shoot()
			shooting_timer = false
			$shooting_timer.start()
			#shooting animation here:
			animation.play("shooting")

		if is_crouching == true:
			shoot()
			shooting_timer = false
			$shooting_timer.start()
			$CollisionShape2D.scale.y = 0.7
			$CollisionShape2D.position.y = 6
			$Node2D/Marker2D.position.y = 4.5
			animation.play("crouch_shooting")
			
	elif Input.is_action_pressed("crouch"):
		animation.play("crouching")
		#animation.play("RESET")
		$CollisionShape2D.scale.y = 0.7
		$CollisionShape2D.position.y = 6
		$Node2D/Marker2D.position.y = 4.5
		is_crouching = true
		velocity.x = 0
	
	else:
		velocity.x = lerp(velocity.x, 0.0, 0.4)
		$CollisionShape2D.scale.y = 1
		$CollisionShape2D.position.y = 1
		$Node2D/Marker2D.position.y = 0
		is_crouching = false
		if shooting_timer == true:
			#idle animation here:
			animation.play("idle")

The collision shape is also changing as he crouch but I don’t think that’s the problem

1 Like

The crouch shooting is actuly playing , the problem is the code plays the normel crouch animation and ignor rendering the crouch shooting animation :expressionless:

Can u sand pic and vid of the problem ?

Bcs im new i cannot…

1 Like

You have a check “if shooting, don’t play the idle”, but you are missing one for “if shooting, don’t play crouch”.

You may need more rigid state machine code soon; look into state machines if you haven’t already, keep in mind it’s optional if you’re not running into too many troubles.

1 Like

I may be dumb but how exactly i can fix this

1 Like

Add a similar check to your crouching animation

elif Input.is_action_pressed("crouch"):
	if shooting_timer == true:
		animation.play("crouching")
1 Like