Why are'nt my Animation Playing

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

extends KinematicBody2D

export (int) var speed = 200

var velocity = Vector2.ZERO
var state_machine

func _ready():
state_machine = $AnimationTree.get(“parameters/playback”)

func get_input():
var current = state_machine.get_current_node()
velocity = Vector2.ZERO
if Input.is_action_pressed(“right”):
velocity.x += 1
if Input.is_action_pressed(“left”):
velocity.x -= 1
if Input.is_action_pressed(“up”):
velocity.y -= 1
if Input.is_action_pressed(“down”):
velocity.y += 1
if velocity.length() == 0:

func _physics_process(delta):
velocity = velocity.normalized() * speed
velocity = move_and_slide(velocity)

Few tips:
You can format your code in the question by selecting it and pressing the { } button above the text editor. This way others won’t have problem reading it and you’ll get the answer faster.
Also it’s better to specify an exact version instead of “latest”, since latest could mean latest stable release, in development build or something else entirely - also if somebody has the same question few years from now, they’ll have even harder time pinpointing if the answer is suitable for their version of godot.

aXu_AP | 2021-11-04 19:40

:bust_in_silhouette: Reply From: aXu_AP

This could possibly be the issue, from the docs:

The state machine must be running before you can travel. Make sure to either call start() or choose a node to Autoplay on Load.