extends KinematicBody export var speed = 20 export var ang_speed = PI export var mouse_sens = 0.2 export var pitch_min = -0.8 export var pitch_max = 0.8 func _physics_process(delta): var local_up = transform.basis.y.normalized() var local_right = transform.basis.x.normalized() var local_forward = -transform.basis.z.normalized() var stick = Input.get_vector("move_left", "move_right", "move_back", "move_forward") var vert = Input.get_axis("move_down", "move_up") var movement = Vector3.ZERO movement += local_right * stick.x * speed movement += local_forward * stick.y * speed movement += local_up * vert * speed movement = move_and_slide(movement, Vector3.UP) stick = Input.get_vector("look_right", "look_left", "look_down", "look_up") var mouse_movement = MouseInput.get_mouse_movement() if stick.length() == 0.0: stick.x = -mouse_movement.x * mouse_sens stick.y = -mouse_movement.y * mouse_sens rotation.x += stick.y * ang_speed * delta rotation.x = clamp(rotation.x, pitch_min, pitch_max) rotation.y += stick.x * ang_speed * delta rotation.y = wrapf(rotation.y, 0, TAU)