class_name Player extends CharacterBody3D const MOVE_SPEED = 4.5 const JUMP_VELOCITY = 4.5 const DECELERATE = 0.75 var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") var move: Vector2 func _input(_event): move = Input.get_vector("move_left", "move_right", "move_forward", "move_backward") func _physics_process(delta): movement() fall(delta) move_and_slide() func movement(): var direction = (Global.camera.transform.basis * Vector3(move.x, 0, move.y)).normalized() # var direction = Vector3(move.x, 0, move.y).normalized() if direction: velocity.x = direction.x * MOVE_SPEED velocity.z = direction.z * MOVE_SPEED else: velocity.x *= DECELERATE velocity.z *= DECELERATE func fall(delta): if is_on_floor(): if Input.is_action_just_pressed("jump"): velocity.y = JUMP_VELOCITY else: velocity.y -= gravity * delta