Godot V4.2.2
Why I Can’t Move?
extends CharacterBody2D
var speed = 180
func _physics_process(_delta):
var _velocity = Vector2()
if Input.is_action_pressed("D_Key"):
$Sprite.play("walk")
$Sprite.flip_h = true
_velocity.x += 1
pass
if Input.is_action_pressed("A_Key"):
$Sprite.play("walk")
$Sprite.flip_h = false
_velocity.x -= 1
pass
if Input.is_action_pressed("W_Key"):
$Sprite.play("walk")
_velocity.y -= 1
pass
if Input.is_action_pressed("S_Key"):
$Sprite.play("walk")
_velocity.y += 1
pass
if _velocity == Vector2():
$Sprite.play("idle")
pass
_velocity = _velocity * speed
move_and_slide()
pass
This Video Explains What I’m Saying : https://drive.google.com/file/d/1rAS3AbLDbX75_OAGNTLTHpYi20eWEK0g/view?usp=drive_link