@onready var spring: SpringArm3D = $SpringArm3D
+@onready var camera: Camera3D = $SpringArm3D/Camera3D
# Called when the node enters the scene tree for the first time.
# horizontal camera rotation
rotation.y -= camera_input_direction.x * delta
+
+
+# Get the XZ input direction based on player's input relative to the camera
+func get_xz_direction_relative_to_camera(d: Vector2) -> Vector2:
+ if camera:
+ var forward := camera.global_basis.z
+ var right := camera.global_basis.x
+ var dir3 := forward * d.y + right * d.x
+ return Vector2(dir3.x, dir3.z).normalized()
+ else:
+ return Vector2.ZERO