3D movement,mouse shaking please help last question is delete

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By abbos

Hi, a friend sent me this code to move in 3D and to rotate the camera by shaking the mouse, but the camera only moves in the y-axis and the character does not move

var speed var gravity = 0 var walk = 10 # walk speed var sprint = 20 # sprint speed var jump = 15 # jump height var fall = 0.7 # fall speed var xsens = 0.08 # mouse x sensitivity var ysens = 0.07 # mouse y sensitivity func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) func _input(event): if event is InputEventMouseMotion: var m = event.relative var r = clamp($Camera.rotation_degrees.x - m.y * ysens,-70,70) $Camera.rotation_degrees.x = r rotation_degrees.y -= m.x * xsens func _physics_process(delta): var dir = Vector3() if Input.is_key_pressed(KEY_SHIFT): speed = sprint else: speed = walk if is_on_floor(): if Input.is_key_pressed(KEY_SPACE): gravity = jump else: gravity = 0 else: gravity -= fall dir.x = int(Input.is_key_pressed(KEY_D)) dir.x -= int(Input.is_key_pressed(KEY_A)) dir.z += int(Input.is_key_pressed(KEY_S)) dir.z -= int(Input.is_key_pressed(KEY_W)) dir = global_transform.basis.xform(dir.normalized()*speed) dir.y = gravity move_and_slide(dir,Vector3.UP)
:bust_in_silhouette: Reply From: Frog studio

You can find and download the answer for your question with this Github link: