How to get an index of an animation track ?

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

Inside my char (KinematicBody2D), I’ve an AnimationPlayer and I want to get the index of a track of the animation:


The script is on the KinematicBody2D like follows:

onready var animMove = $AnimMove  # This is the AnimationPlayer

func _physics_process(delta):
    var trackAnimPath = "AnimMove/Head:frame"
    var startAnim = animMove.get_animation("walk_down")
    var animIdx = startAnim.find_track(trackAnimPath)
    print("animIdx: " + str(animIdx))

Then unfortunately to me, its returning: animIdx: -1
Please, what is the correct way to do it ?

:bust_in_silhouette: Reply From: Victoralm

oh mine, I’ve just change:

var trackAnimPath = "Head:frame"

Its working now…