My character keeps going backwards

Godot Version

The newest one


I don’t know what is wrong I made this easy proggram to move my character and it goes back whenever i start the game
The code:

extends CharacterBody3D
var speed = 5
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if Input.is_action_pressed("ui_up") or Input.is_key_pressed(KEY_W):
		position.z += delta * speed
	if Input.is_action_pressed("ui_down") or Input.is_key_pressed(KEY_S):
		position.z -= delta * speed
	if Input.is_action_pressed("ui_right") or Input.is_key_pressed(KEY_D):
		position.x += delta * speed
	if Input.is_action_pressed("ui_left") or Input.is_key_pressed(KEY_A):
		position.x -= delta * speed

How do you define “back” in 3D? Maybe the problem is in your camera orientation?
Anyway, you shouldn’t set the position directly for RigidBody3D or CharacterBody3D. Just change the velocity vector and call move_and_slide(). Godot will do the rest.

I fixed the problem :slight_smile: