0
\$\begingroup\$

I was perfect as I could possibly be with this code but for some reason every time I try to play the game it just breaks. It says "Invalid call. Nonexistent function 'travel' in base 'Nil'." So I'm pretty sure I gotta reinstall Godot because there's legit nothing wrong with the code. I triple checked and it should be working just fine. The issue is with the onready var animationState but that doesn't make sense because there's nothing wrong with that line of code. No typos, no anything. I just want the animations to play when they are moving and not moving. Can someone please tell me what the heck is wrong with this before I throw my computer out the window? Thanks.

extends KinematicBody2D

const ACCELERATION = 500
const MAX_SPEED = 80
const FRICTION = 500

var velocity = Vector2.ZERO

onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("perameters/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/Walk/blend_position", input_vector)
        animationState.travel("Walk")
        velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
    else:
        animationState.travel("Idle")
        velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
    
    velocity = move_and_slide(velocity)
\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Answering for completeness sake. This is pretty straightforward to debug: only animationState uses the function 'travel', and the error clearly states that that variable is Nil, so it wasn't properly initialized. Double checking the corresponding line shows the typo: 'paremeter' instead of 'parameter'.

\$\endgroup\$
-1
\$\begingroup\$

It was a typo, my bad. Got the answer from a different Q&A

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Can you clarify what the typo was and how you fixed it, so this can help other users in the future? \$\endgroup\$
    – DMGregory
    Dec 7, 2020 at 1:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .