i was able to get the body to move and rotate in 3d but when the body is rotated, it doesnt go forward in the local axis, only global. I looked everywhere but havent found anything useful
``extends CharacterBody3D
@onready var plrBody = self
var currentSpeed = Vector3.ZERO
var plrSpeed = 2
var acceleration = 8
@export var plrMouseSens = 1.2
@onready var plrCamera = $PlrCamera
func _physics_process(delta):
keyInput()
move_and_slide()
func keyInput():
var direction = Vector3.ZERO
if Input.is_action_pressed("move_forward"):
direction.z -= plrSpeed
if Input.is_action_pressed("move_back"):
direction.z += plrSpeed
if Input.is_action_pressed("move_left"):
direction.x -= plrSpeed
if Input.is_action_pressed("move_right"):
direction.x += plrSpeed
CharaMovement(direction)
func CharaMovement(direction):
plrBody.set_velocity (plrBody.velocity.lerp(direction, get_process_delta_time() * acceleration))
print(plrBody.velocity)
func _input(event):
if event is InputEventMouseMotion:
mouseLook(event)
func mouseLook(event):
plrBody.rotation.y += event.relative.x * -1 * plrMouseSens * get_process_delta_time()
plrCamera.rotation.x += event.relative.y * -1 * plrMouseSens * get_process_delta_time()``