animated tree playing the autoplay animation frame at the start of each animation

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

The animatedTree has “Idle” as my autoplay node. Due to this during each iteration, first frame of this node is played before the start of any animation,
eg: Idle - > Run → Idle → Run instead of Idle - > Run → Run

Do you have any solution to this problem?

The code:

extends KinematicBody2D
class_name Actor

const FLOOR_NORMAL: = Vector2.UP

var jump_count:= 0
export var gravity: = 30.0
export var speed: = 300.0
export var jump = -1000.0

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 = true
	can_idle = true
	on_floor = true

func _process(delta):
	match state:
			sprite_main.visible = true"Running")
			sprite_main.visible = true"Idle")
			sprite_main.visible = true"Jump Start")
		"Mid Jump":
			sprite_main.visible = true"Jump Mid")
		"Punch I":
			sprite_main.visible = true"Punch I")
		"Punch II":
			sprite_main.visible = true"Punch II")

func _physics_process(delta:float) -> void:
	var is_jump_interrupted: = Input.is_action_just_released("jump") and velocity.y< 0.0
	velocity.y += gravity
	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
	var on_ground = is_on_floor()
	if not on_ground:
		state = "Mid Jump"
		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"):

func normal_attack():
	if punch2 == true:
		state = "Punch II"
		can_idle = false
		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 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”