Godot Version
4.5.1 stable (on Apple M1 Pro)
Question
Hey all, first time posting. I’m completely new to Godot and programming, so please bear with me.
I’m following a short intro to Godot course. (I realize now it’s going to make more sense for me to start by learning the basics of programming first, but I figured I’d see this course through before going that way.) Everything had been going well and we’re now at the part where we’re creating a quick little coin collector game to put everything we’ve learned together.
First up is player movement. Despite my code being exactly the same as the instructor’s, I cannot get the arrow keys to work at all when I run the scene. The character sprite will not budge.
Here’s the code:
extends CharacterBody2D
var speed : float = 100
func _physics_process(delta):
velocity.x = 0
velocity.y = 0
if Input.is_key_pressed(KEY_RIGHT):
velocity.x += speed
if Input.is_key_pressed(KEY_LEFT):
velocity.x -= speed
if Input.is_key_pressed(KEY_UP):
velocity.y -= speed
if Input.is_key_pressed(KEY_DOWN):
velocity.y += speed
move_and_slide()
And in case that doesn’t show up properly, here’s a screenshot so you can see my formatting.
I tried assigning other keys instead of the arrows and still no dice. Is there something I’m overlooking?
