extends AnimationTree
var _playback: AnimationNodeStateMachinePlayback
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
_playback = get("parameters/playback")
_playback.start("idle")
active = true # make the animation active
func _make_active(myanimation) -> void:
_playback.travel(myanimation)
func _whatisplaying():
return _playback.get_current_node()
I then call _make_active("laugh") to play the animation.
To see what is playing: _whatisplaying()
Thanks!
Is there any way to get/set the progress of the animation? I want to sincronize the animation in multiplayer, so i want to get/set not just the animation but also the exact point in the animation, if i use current animation position of animationPlayer it gives me 0.
2plus2makes5 | 2020-05-21 17:37
Yeah, not sure about that one. I’ve tried as well to get the position, but I also get 0.
deaton64 | 2020-05-22 07:43
Thanks again, i’ll try opening an issue.
2plus2makes5 | 2020-05-22 08:41
What I’ve done is to export a float variable from a script and set the first key frame on the animation to 0 and the last keyframe to whatever length you have for that anim. If your animation is 0.8, you would put a keyframe with 0.8 value at the end.
This way, the anim player will set the value of that var to the position of the animation. This works great if you have a blendtree and are changing the time scale of the animation.