I’ m using godot 4.3 version and i have just started learning game development. I am following a tutorial by “Brackeys” on game dev for beginners. My 2d player won’t move and I have no idea why, I checked the script and followed along every step. I’m attaching an image of the code, if you need any more information I’ll provide that too.
What’s the script attached to
Did you bind keys to “ui_left” and “ui_right”? It’s in Project Settings → Input Map
you have to tell move_and_slide() where to move, like so:
move_and_slide(velocity, Vector2.UP)
you have to tell move_and_slide() where to move, like so:
move_and_slide(velocity, Vector2.UP)
No, the move_and_slide function does not take any inputs (At least, not anymore?). Instead, you set the velocity, and move_and_slide does the rest. CharacterBody2D — Godot Engine (stable) documentation in English
bool move_and_slide()
Moves the body based on velocity.
How do you know the character isn’t moving?
In your scene tree, I see a staticBody2D, but I don’t see any visual elements. Because the camera is a child of the player, the camera will move with the player. Without some reference point (i.e. a colorRect or sprite2D), the background will stay the same and the player will stay in the center of the screen. This will look like the player isn’t moving, even if they are.
P.S. It might be a little helpful if you were to link the video and a timestamp of where you stopped.
Could print the coordinates too
I saw now that it was because of the camera being a child node of the player. Thankyou for taking out the time to reply.