AnimatedSprite only plays 1 frame

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

when the AnimatedSprite move its only playing one frame.I Make all frames and make a looooooooong scripts but its only works one frame i recheck but it doesn’t so any solution?
this is a top down game
Here my script,

` extends KinematicBody2D

export (int) var speed = 200

var velocity = Vector2()

func get_input():
velocity = Vector2()
if Input.is_action_pressed(“ui_right”):
velocity.x += 1
$AnimatedSprite.play(“Runside”)
else:
$AnimatedSprite.play(“Idle”)
if Input.is_action_pressed(‘ui_left’):
velocity.x -= 1
$AnimatedSprite.play(“Runside”)
if Input.is_action_pressed(‘ui_down’):
velocity.y += 1
$AnimatedSprite.play(“rundown”)
if Input.is_action_pressed(‘ui_up’):
velocity.y -= 1
$AnimatedSprite.play(“Runup”)
velocity = velocity.normalized() * speed

func _physics_process(delta):
get_input()
velocity = move_and_slide(velocity)`

note:I am a total noob at scripting and making games pls help
Edit:sorry p7f i cannot see a button in tool but i see {} which make no sense

Would you share a project so i can check? Also, i recommend you that when you paset code here, you use the code sample format (there is a button in the toolbar when you write messages) So we can understand it.

p7f | 2020-06-30 12:53

when player press wasd it only works one frame that i made

Do you know how to share the project because this is my first time in Q&A also i cant upload any images really

sihela | 2020-06-30 18:02

:bust_in_silhouette: Reply From: Jorge

Hi,
you need to copy your code correctly as there is some typos that affect the code, however, i can see in your code that you initial velocity is Vector2() ,(and repeated 2 times in your script) , that means velocity.x = 0 and velocity.y = 0 , and the last line you need to check the correct variables, you are missing some.

I would recommend just to look the step by step 1st game of godot docs, the explain what just I mentioned but more clear.

good luck

it worked Thank you

sihela | 2020-07-01 04:50