I'm attempting to have it so that the player switches between two different animation states using an animation tree upon a user input.
Currently I'm using an if statement that checks if the current animation tree node is equal to a string (the name of one of the nodes), traveling to the other node if they are, and traveling to the other if they aren't.
As it is, the transition works only when they aren't equal, so I tried printing whatever
get_current_node() returns to see what I get, but when I did that nothing showed up in the output, and me being new to this, I thought maybe things that return null return nothing when printed, so I simply printed null, and that printed out the word Null just fine.
I'm still very now to godot and have very limited coding experience, so I'm certain there's a better way to approach this, but I still don't understand why
get_current_node() isn't returning anything. I receive no errors in the editor at any point.
This is the code I'm running:
export var ACCELERATION = 500
export var MAX_SPEED = 90
export var FRICTION = 350
export var ROLL_SPEED = 500
var state = MOVE
var velocity = Vector2.ZERO
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
onready var animationPlayer = $AnimationPlayer
onready var currentAnimationState = animationState.get_current_node()
animationTree.active = true
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
state = DASH
#change color state
if currentAnimationState == "IdleRed":
state = MOVE
velocity = move_and_slide(velocity)