AnimationTree is weird and plays wrong animation

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

Heres the code

    extends KinematicBody2D

var motion=Vector2()
const UP =Vector2(0, -1)
const GRAVITY = 100
const SPEED = 1000
const JUMP_HEIGHT = -2500
var state_machine 

func _ready():
	state_machine = $Node2D/AnimationTree.get("parameters/playback")

func _physics_process(delta):
	motion.y +=GRAVITY
	if Input.is_action_pressed("ui_right"):
	elif Input.is_action_pressed("ui_left"):
		motion.x = 0"Idle")
	if is_on_floor():
		if Input.is_action_just_pressed("ui_up"):
			motion.y = JUMP_HEIGHT
	motion = move_and_slide(motion, UP)
	motion = move_and_slide(motion, UP)

Heres a video

point is it travels to “air” instead of "run. its not very visible in the video but take my word

Have you tried putting a breakpoint on the line"air")

to see if you hit it while you’re running? Perhaps your character is briefly leaving the ground while running.

Bernard Cloutier | 2020-01-24 15:12

What do you mean by breakpoint?

Anastasia | 2020-01-24 16:54