Character 2D, Didn't detect input

Godot Version

V 4.4.1

Question

Hello, I recently just discover Godot and decided to create my brand new 2D game project. So as you probably know, I was searching for Godot 2D Top-Down game tutorial, and decided to follow the tutorial.

At first, nothing happens, but when i try to move my character, it didn’t move at all. On the debug window, I must press the “Input” and “Override In-Game Camera” in order to make my character move, is this an issue, should I just let it be? Or should I try something else rather than manually selecting “Input” and “Override In-Game Camera” to make movements?

I really need help, and it would be very lovely, thankss!

Notes:
If you wonder if I already add velocity, yes I already did. ui_left, right etc, yes I already did, input map too, I also add AWSD. I also add Camera2D to make my character on the center. And yes, i already add collision2D too. And yes, the script is already correct, in fact my character can move when I select the “Input” and “Override In-Game Camera” is already a proof. And yes, i have debugged it using the print in console. And yes, i have save the scene.

Hello, It’s not very easy to identify the issue without seeing the code.
You can just copy and paste the code into the post and then formatting it as code. That makes it a lot easier to help instead of reading the “notes”

1 Like

sure here is the code:

player.gd

extends CharacterBody2D

var speed = 100;

func _physics_process(delta):
	player_move(delta)

func player_move(delta):
	if Input.is_action_pressed("ui_right"):
		velocity.x = speed;
		velocity.y = 0
	elif Input.is_action_pressed("ui_left"):
		velocity.x = -speed;
		velocity.y = 0
	elif Input.is_action_pressed("ui_down"):
		velocity.y = speed;
		velocity.x = 0
	elif Input.is_action_pressed("ui_up"):
		velocity.y = -speed;
		velocity.x = 0
	else:
		velocity.x = 0
		velocity.y = 0
	
	move_and_slide()

Also this for the debug window. it can only move if i press 1 and 2

I dont really have any experience with top downs but my best guess would be that you didn’t follow the tutorial properly. Which tutorial are you following?

1 Like

Its DevWorm. Here’s the playlist:

I think you just need to remove the semicolons and then it should work

like so:

extends CharacterBody2D

var speed = 100

func _physics_process(delta):
	player_move(delta)

func player_move(delta):
	if Input.is_action_pressed("ui_right"):
		velocity.x = speed
		velocity.y = 0
	elif Input.is_action_pressed("ui_left"):
		velocity.x = -speed
		velocity.y = 0
	elif Input.is_action_pressed("ui_down"):
		velocity.y = speed
		velocity.x = 0
	elif Input.is_action_pressed("ui_up"):
		velocity.y = -speed
		velocity.x = 0
	else:
		velocity.x = 0
		velocity.y = 0
	
	move_and_slide()
1 Like

Hi, i’ve tried this, wont work either, thanks for the syntax correcting!

The issue is probably somewhere in the camera settings.

My best advice would be to go through the video and make sure that you did everything exactly as he did.
I’m sorry i couldn’t help you more :frowning:

1 Like

It’s okay, you’ve tried, thankss

Never mind. I found the issue! Hehe my bad, I accidently colliding the CollideShape2D with AnimatedSprite2D, and Camera2D is not functioning and didn’t needed right now for debugging :joy: