Okay I have this figured out. So firstly you are looking to interpolate between these states. I have done some code in relation to my own character controller with a BlendSpace2D and I will post the relevant code below
So I utilize these variables and initialize the walk_transition (which is the current value) in the _ready function, then through the controller's directional function I grab the "target value" (which is the movement_state, or the value being interpolated to), then in the animation handler function I actually do the interpolation and use the walk_transition value as the blendspace value.
#ANIMATION VARIABLES
onready var animation_tree = get_node("AnimationTree")
onready var animation_mode = animation_tree.get("parameters/playback")
var movement_state : Vector2
var walk_transition : Vector2
export var transition_speed : float = 5
func_ready():
walk_transition = Vector2(0, 0) #Initialize walk transition vector.
func _physics_process(delta):
_handle_movement(delta)
_handle_animation(delta)
func _handle_movement(delta):
movement_state = Vector2()
if can_move:
#DIRECTIONAL MOVEMENT
if Input.is_action_pressed("move_forward"):
movement_state.y += 1
if Input.is_action_pressed("move_backward"):
movement_state.y += 1 #Change to -= 1 when walk_b animation is implemented
if Input.is_action_pressed("move_left"):
movement_state.x -= 1
if Input.is_action_pressed("move_right"):
movement_state.x += 1
func _handle_animation(delta):
#DIRECTIONAL MOVEMENT
walk_transition = walk_transition.linear_interpolate(movement_state, acceleration * delta)
animation_tree.set("parameters/movement_state/blend_position", walk_transition)
As stated, I only put the relevant pieces in this comment, if anyone is interested in the character controller for their own projects, I am more than happy to share it. If you have any question, let me know and I will help where I can.