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".

a year later

I don't know if this'll get res'd or if there's a bug report for this already, but I'm having the same issue. I'm trying to make a combo system using the state machine and was hoping to rely on "get_current_node()" as a condition to move on with a combo, but it ALWAYS returns "idle", despite the transitions out of idle being "Immediate".

2 years later

I'm not sure if this will work, but here's something to try. How about instead of putting the code in the input event, you make the input event change a variable, and then put an elif in the if on floor to check if the variable is true. In the animation player, you can make isEating = false once the animation stops playing, by using an animation_finsihed() function (you need to add it in the animation player at the end of the animation to emit the signal.

var isEating = false
func _input(event):
    if event is InputEventKey
        if event.pressed and event.scancode == KEY_1:
            isEating = true

#function below should automatically appear when you add the animation finished to the animation player
func _eatingAnimationFinished():
	isEating = false

#and then in the intergrate forces function
    if on_floor:
        if isEating == true:
            playback.travel("eat")
        elif abs(lv.x) < 0.1:
            playback.travel("idle")
        else:
            playback.travel("walk")

hopefully this works :)

11 days later

I'm sorry! I lose my project files.

a year later