0 votes

extends KinematicBody2D

export (int) var speed = 200

var velocity = Vector2.ZERO
var state_machine

func ready():
machine = $AnimationTree.get("parameters/playback")

func getinput():
var current = state
velocity = Vector2.ZERO
if Input.isactionpressed("right"):
velocity.x += 1
if Input.is
velocity.x -= 1
if Input.isactionpressed("up"):
velocity.y -= 1
if Input.is
velocity.y += 1
if velocity.length() == 0:

func physicsprocess(delta):
velocity = velocity.normalized() * speed
velocity = move

Godot version latest
in Engine by (27 points)

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.

1 Answer

0 votes

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.

by (1,100 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.