0 votes

This is my script

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 = move

Godot version latest
in Engine by (27 points)

Are you receiving any error messages? Also, have you checked to make sure the input map is set up properly?

2 Answers

+1 vote

Every physics frame you reset the velocity to zero and only ever increment it by 1 in any direction then you feed that velocity into move_and_slide() then on the next frame you're resetting your velocity back to 0. It's likely that you're moving but very slowly at about 1 pixel per second.

You need to incorporate your speed variable into this by adding:

velocity = velocity.normalized() * speed

to the bottom of your get_input() function. Doing so should fix your problem.

by (3,707 points)

now my character is moving but no animations are playing

0 votes

lol my bad i dint have a start animation

But how would i cause my sprite to face the way i run when playing idle
rn its only playing a down facing idle i have a right a left and a up idle

by (27 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 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 webmaster@godotengine.org with your username.