I can't get state machine current animation name in _integrate_forcess

No_IENo_IE Posts: 7Member
edited January 31 in Programming

Hello! My code like this:

func _ready():
    playback = $AnimationTree.get("parameters/playback")
    playback = start("idle")
#
func _integrate_forces(s)
    var lv = s.get_linear_velocity()

    print(playback.get_current_node()) #it is "idle" or "walk" always.
    if playback.get_current_node() == "eating":
        return

    if on_floor:
        if abs(lv.x) < 0.1:
            playback.travel("idle")
        else:
            playback.travel("walk")
#
func _input(event):
    if event is InputEventKey
        if event.pressed and event.scancode == KEY_1:
            playback.travel("eating")
            print(playback.get_current_node()) #it is "idle" or "walk" too.

But the playback.get_current_node() is "idle" or "walk" always. So the game can't play "eating" animation.

I use Godot Engine v3.1.beta3. the code from Dynamic Character Control-Based Platformer Demo".

Tagged:

Tags :
Sign In or Register to comment.