My Character won't move

Godot Version

extends CharacterBody2D

func _physics_process(delta):
	if Input.is_action_pressed("right"):
		velocity.x = 4
	elif Input.is_action_pressed("left"):
		velocity.x = -4
	else:
		velocity.x = 0
	move_and_collide(velocity)

Question

I’m new to this, have been following video, but my player won’t move. does anyone have a solution?

did you set left, right input in project settings?

1 Like

yes, I have them set for arrow keys and WASD

Not to take your word for granted, but in simple issues like this it would be nice to have visual proof of your situation (Relevant project settings, character node tree etc.). It helps to build the context for those trying to help.

1 Like

image

image

You have to use the exact name when getting input action. You assigned your inputs in “ui_left” and “ui_right”
if Input.is_action_pressed("ui_right"):

3 Likes