2D Character Controls

Godot Version

Godot 4.2.2

Question

So I am trying to add in movement for a 2d character and odnt know why this isnt working as as far as i know it should be any ideas?

extends CharacterBody2D

@export var speed = 400

func get_input():
	var input_direction = Input.get_vector("wleft", "wright", "wforward", "wback")
	velocity = input_direction * speed

func _physics_process(delta):
	get_input()
	move_and_slide()

Looks like it should work. Maybe use a print statement on velocity. Or just use “ui_left” etc. to see if the mapping is right.

2 Likes

I must have been just way too tired. I forgot to attach the script to the character at all sorry haha.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.