Animation in blend space 2D overlapping in animation tree

Godot Version

4.5

Question

Hi - I’m seeing overlap in animations when travelling between them when velocity changes. It seems to only happen when I set both the ‘Walk’ and the ‘Idle’ blend positions in the same block of code. I need both so that when the character stops, they face the correct way when idle






extends CharacterBody2D

@export var speed: int = 100
@onready var anim_tree: AnimationTree = get_node("AnimationTree")

func get_input():
	var input_direction = Input.get_vector("left", "right", "up", "down")
	velocity = input_direction * speed


func _physics_process(_delta):
	get_input()
	handle_animation()
	move_and_slide()


func handle_animation():

	
	if velocity == Vector2.ZERO:
		anim_tree.get('parameters/playback').travel('Idle')
		
		
	else:
		anim_tree.set('parameters/Walk/blend_position', sign(velocity))
		anim_tree.set('parameters/Idle/blend_position', sign(velocity))
		anim_tree.get('parameters/playback').travel('Walk')

Honestly, I’m not entirely sure what the issue was, but I got around it with this workaround

func handle_animation():
	if velocity == Vector2.ZERO:
		walking = false
	else:
		walking = true

	anim_tree.set("parameters/conditions/idle", !walking)
	anim_tree.set("parameters/conditions/walking", walking)
	
	if last_direction:
		anim_tree.set("parameters/Walk/blend_position", last_direction)
		anim_tree.set("parameters/Idle/blend_position", last_direction)
  • Deleted the ‘frame’ track in the RESET animation. (I think this is the part that fixed it)

However, though it’s not breaking, I do get this error in the debugger now

E 0:00:01:034   set_parameter: Condition "!process_state->tree->property_parent_map.has(node_state.base_path)" is true.
  <C++ Source>  scene/animation/animation_tree.cpp:91 @ set_parameter()