- Edited
I accidentally made a discussion about this but anyways I'll go ahead and write down what I put earlier. I have been trying to fix this issue for hours, watching videos, and the documentation. It is not the AnimationTree because it is active and a part of the child of the script holder. I can't seem to figure this out and it doesn't work with the void start function either.
extends KinematicBody2D
export (int) var speed = 200
var velocity = Vector2()
var statemachine
func ready ():
statemachine = $AnimationTree.get("parameters/playback")
func get_input():
velocity = Vector2()
if Input.is_action_pressed("right"):
velocity.x += 1
statemachine.travel("sprint")
elif Input.is_action_pressed("left"):
velocity.x -= 1
elif Input.is_action_pressed("down"):
velocity.y += 1
elif Input.is_action_pressed("up"):
velocity.y -= 1
else:
velocity.x = 0
statemachine.travel("idle")
velocity = velocity.normalized() * speed
func _physics_process(delta):
get_input()
velocity = move_and_slide(velocity)
Hopefully someone can help me. Also the strings are exactly the names of the actual playback animations.