Question about status

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

My motion gets stuck on scrolling, as long as velocity != vector.ZERO it breaks the scrolling animation and plays the moving animation.

func _process(delta):
match state:
	MOVE:
		move_state(delta)
	ROLL:
		roll_state(delta)
rotate(delta)

func roll_state(delta):
velocity = roll_vector * ROLL_SPEED
animationState.travel("Roll")
move()

func rotate(delta):
var dir = Vector2(1,0).rotated($Gun.global_rotation)
dir = (dir / 3.14)*180
if dir.x <= 35 and dir.y >= -35 && dir.x <= 35 and dir.y <= 35:
	if velocity != Vector2.ZERO && Input.is_action_just_pressed("Roll"):
		animationState.travel("Run")
	if Input.is_action_just_pressed("Roll"):
		roll_state(delta)
	else:
		animationState.travel("Idle")
	$Gun.flip_v = true
:bust_in_silhouette: Reply From: Inces

Your if statements are independent from each other.
First one goes : if velocity != zero and input is roll , it induces Run motion. But the next line, that goes : if input is roll, is also true when first one is true, and it overrides Run with Roll.

If You need if statements to be dependant from each other, You need to use elif and else constructors