Help with the WASD keys

Godot 3.5.3

The WASD keys only move to the global axis, and not relative to the kinematic body’s view

Its difficult to explain, when i move forward with the W facing the sun, and then decide to move right., the key will still go to the sun direction and not in relation to the camera’s view. How to fix this?

Here’s my script so far:

func _physics_process(delta):
	var input_dir = Vector3.ZERO
	if Input.is_action_pressed("ui_up"):
		input_dir.z -= 1     
	if Input.is_action_pressed("ui_down"):
		input_dir.z += 1
	if Input.is_action_pressed("ui_right"):
		input_dir.x += 1
	if Input.is_action_pressed("ui_left"):
		input_dir.x -= 1
    
    if input_dir != Vector3.ZERO:
		input_dir = input_dir.normalized()*speed
	if input_dir != Vector3.ZERO:
		direction = (transform.basis.x*input_dir.x)+ (transform.basis.z*input_dir.z)
		direction.y - 0
		direction = direction.normalized()

     
        func _ready ():
	Input.set_mouse_mode (Input.MOUSE_MODE_CAPTURED) 
func _input (event):
	 if event is InputEventMouseMotion:
		 rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
		 head.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))  
		 head.rotation_degrees.x = clamp(head.rotation_degrees.x, -90, 90)
 

multiply the basis by your input_dir directly, you are not applying any rotation to the input_dir by doing this per-component. Your direction.y - 0 does nothing, you probably meant to use an equals sign instead.

direction = transform.basis * input_dir
direction.y = 0
direction = direction.normalized()

If you want to use wasd for moving, you should define your own input actions, not reassign the ui_* actions to wasd. The ui_* actions are used by Godot for the UI, hence their name.