Im getting a debug invalid call nonexistent function "travel" in base Nil. I cant find any problem with it. pls help

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TanXBro
extends KinematicBody2D

const ACCELERATION = 500
const MAX_SPEED = 100
const FRICTION = 500

var velocity = Vector2.ZERO

onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationPlayer
onready var animationState = animationTree.get(“parameters/playback”)

func _physics_process(delta):
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:
	animationTree.set("parameters/Idle/blend_position", input_vector)
	animationTree.set("parameters/Run/blend_position", input_vector)"Run")
	velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)		
	velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity = move_and_slide(velocity)
:bust_in_silhouette: Reply From: timothybrentwood

If a node resolves to nil (or nothing) it’s usually a timing issue. Try changing

onready var animationState = animationTree.get("parameters/playback")


onready var animationState = $AnimationPlayer.get("parameters/playback")

You may have to just declare animationState as a normal variable then in the _ready() function assign it to $AnimationPlayer.get("parameters/playback")