Hi i've started programming or learning to code, and while i'm certain the script is okay, the player sprite just doesn't move

Godot Version

extends CharacterBody2D

const SPEED = 300.0
const JUMP_VELOCITY = -850.0

func _physics_process(delta: float) → void:

print("Physics is running")

var direction = Input.get_axis("left", "right")

if not is_on_floor():
	velocity.y += get_gravity().y * delta

if Input.is_action_just_pressed("jump") and is_on_floor():
	velocity.y = JUMP_VELOCITY

if direction != 0:
	velocity.x = direction * SPEED
else:
	velocity.x = move_toward(velocity.x, 0.0, SPEED)

move_and_slide()

Question

Hi sorry to bother everyone but I need help with some coding. I don’t have any experience with coding or video game design. I’mtrying to create a very simple platformer with the goal of having a character move left and right and jump on the platforms. the issue is whenever I run the scene, I cannot move the player character at all. My keyboard does work and I've followed youtube tutorials, but I;m getting nowhere,and for some reason, the scene does not play. The nodes look okay and the colison effect is there.

Have you assign input name “left” “right” " jump"?
In project > project setting > input map and re name them.

If you don’t have anything else there, it could look like you don’t move as the camera follows the player.

Add this in physics process:

print("Position: ", global_position)

If you see it changing in the prints, you are moving.

One more thing worth checking is whether the correct scene is set as the Main Scene under Project → Project Settings → Application → Run.

Also, make sure the script is attached to the CharacterBody2D node and that the Input Map actions match the names used in your code.

i think so but i’ll doublecheck. so include the quotation marks right?

thank you, I will do, lets hope it works

i did and still not working

No, you don’t include the quotation marks when you enter it in the input map. You only use quotation marks when checking what input is pressed/released/etc.

So in input map, if you have an action called right, you just enter it as: right. When you want to work with it in your code, you write it “right”. The double quotation marks are there because the original name (right) is a string. Double quotation marks means “the characters between us is a string”.

Do you get any warnings or errors in your debugger or ouptut panel? Does your print statement “Physics is running” print rapidly for every frame?