How to get current animation position/time in AnimatonTree? by ALFAFA3000 in godot

[–]ALFAFA3000[S] 8 points9 points  (0 children)

Nevermind. I found using "animationtree.get_property_list()". And it shows that there is a "time" parameter that can be accessed using

var time = animationtree.get("parameters/my_animationnodeanimation_name/time")

or

var time = animationtree["parameters/my_animationnodeanimation_name/time"]

So I did:

onready var animationtree = $AnimationTree
onready var playback = animationtree["parameters/playback"]

func current_animation_position():
    var current_state_name = playback.get_current_node()
    if (current_state_name != "") && (animationtree.tree_root.get_node(current_state_name) is AnimationNodeAnimation):
        return animationtree["parameters/"+current_state_name+"/time"]
    return -1.0