You probably want to set animationState
in the _ready
function rather than using onready
since animationTree
is also being set using onready
. Personally, I'd suggest setting both variables in _ready
, just so you know that they are both set and their functions usable:
var animationTree : AnimationTree
var animationState
func _ready():
animationTree = $AnimationTree
animationState = animationTree.get("parameters/playback")
Though as @NeoD mentioned, you probably want to make sure that the script is properly attached to the Player node.