when writing this script I was stupid and now no matter your rotation you always move in two certain directions on the x axis instead of up and down based on your rotation
extends CharacterBody3D
@export var speed = 5
var jump_velocity = 5
var move_direction = Vector3()
var _velocity = Vector3()
var gravity = 5
var rot
func _physics_process(delta):
if not is_on_floor():
_velocity.y -= gravity * delta
move_direction.z = Input.get_action_strength("up") - Input.get_action_strength("down")
rot = Input.get_action_strength("right") - Input.get_action_strength("left")
if Input.is_action_just_pressed("jump") and is_on_floor():
_velocity.y = jump_velocity
_velocity.z = move_direction.z * speed
velocity = _velocity
rotate_y(rot)
move_and_slide()
it is for a basic first person character which right now is just a characterbody3D (not kinematicbody3D cause godot 4) with a meshinstance, camera and collisionshape