![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Jordex |
I’m learning to do progamation, I’m new in the Godot engine, my first code make the character play the animation, but he don’t move, can someone explain me why?
extends Area2D
export var speed = 400
var screen_size
func _ready():
pass
func _process(delta):
var velocity = Vector2() # The player’s movement vector.
if Input.is_action_pressed(“ui_right”):
velocity.x += 1
if Input.is_action_pressed(“ui_left”):
velocity.x -= 1
if Input.is_action_pressed(“ui_down”):
velocity.y += 1
if Input.is_action_pressed(“ui_up”):
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized()*speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()