AnimationTree playing first frame of my autoplay animation during other animations

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

Hi, Whenever I want my character perform an action, the unwanted animation frame is played before the wanted animation.
For eg: If i want my character to move right by “running”, then the “Idle” animation frame is displayed then the character moves to the right by “running” animation
I have kept “Idle” animation as autoplay on Start in animationTree, I think that in each iteration the player starts at this point, displays the frame then jumps to the necessary animation. But I can’t remove the autoplay as without the autoplay it gives me error saying “State Machine not playing”. Any help is very much appreciated.

onready var sprite_main = $CompleteSprite
onready var animation = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")

var double_jump_bool = false
var velocity: =  Vector2.ZERO
var state = "Idle"
var can_idle: bool
var on_floor: bool
var face_left: bool
var punch1 = false
var punch2 = false

func _ready():
	sprite_main.visible = true
	animationTree.active = true
	can_idle = true
	on_floor = true

func _physics_process(delta:float) -> void:
	var is_jump_interrupted: = Input.is_action_just_released("jump") and velocity.y< 0.0
	velocity.y += gravity
	get_input()
	get_state(state, face_left)
	velocity = move_and_slide(velocity, FLOOR_NORMAL)

func get_input():
	velocity.x = (Input.get_action_strength("move_right") - Input.get_action_strength("move_left"))*speed
	get_direction()
	
	var on_ground = is_on_floor()
	if not on_ground:
		state = "Mid Jump"
	else:
		if velocity.x != 0:
			state = "Run"
		if Input.is_action_pressed("jump"):
			velocity.y = jump
			state = "Jump"
		if velocity.x == 0 and can_idle == true:
			state = "Idle"
	if Input.is_action_pressed("punch"):
		normal_attack()

func normal_attack():
	if punch2 == true:
		state = "Punch II"
		can_idle = false
	else:
		state = "Punch I"
		can_idle = false

func get_direction():
	if velocity.x < 0:
		sprite_main.flip_h = true
		face_left = true
	elif velocity.x > 0:
		sprite_main.flip_h = false
		face_left = false 

func get_state(state,face_left):
	print(state)
	match state:
		"Run":
			sprite_main.visible = true
			animationState.travel("Running")
		"Idle":
			sprite_main.visible = true
			animationState.travel("Idle")
		"Jump":
			sprite_main.visible = true
			animationState.travel("Jump Start")
		"Mid Jump":
			sprite_main.visible = true
			animationState.travel("Jump Mid")
		"Punch I":
			sprite_main.visible = true
			animationState.travel("Punch I")
		"Punch II":
			sprite_main.visible = true
			animationState.travel("Punch II")

func punch_1_animation_finished():
	punch1 = true
	can_idle = true
:bust_in_silhouette: Reply From: Newbie_101

I solved this by turning off autoplay on load option in AnimationPlayer which was on for “Idle”