Movement not working

Godot Version

4 .net version

Question

I’m a new dev making a game for school and can’t get my movement to work, this is my code. I added the input map aswell. The script is connected since the gravity is working.

using Godot;
using System;

public partial class Player : CharacterBody2D
{
	[Export] public float Speed = 200f;
	[Export] public float JumpVelocity = -350f;
	

	public override void _PhysicsProcess(double delta)
	{
		
		Vector2 velocity = Velocity;

		// Add the gravity.
		if (!IsOnFloor())
		{
			velocity.Y += 980f * (float)delta;
		}

		// Handle Jump.
		if (Input.IsActionJustPressed("jump") && IsOnFloor())
		{
			velocity.Y = JumpVelocity;
		}

		float direction = Input.GetAxis("move_left", "move_right");
		velocity.X = direction * Speed;

		velocity.X = direction * Speed;

		Velocity = velocity;
		GD.Print(direction);
		MoveAndSlide();
	}
}

Unless you have to use C# for some reason, or you are using this to practice your C# skills, I recommend using GDScript before you go any farther. C# is a great language, but the learning curve is much steeper than GDScript when using Godot.

Have you done this tutorial? Your first 2D game — Godot Engine (stable) documentation in English If not, I recommend you start here. (It has a C# version if you need that.)

So gravity works, and I’m assuming your print(direction) is just 0s?

Have you double checked your input setup? By default it has “ui_left” so you have to add the “move_left”, etc.

You’re changing the y velocity and it’s moving accordingly so it’s got to be the input part.

I don’t know the c# equivalent but you could try using the “unhandled input” method and printing the event out to make sure events are getting to your node.