From 8b0cbb6f47c07ed2329e2602d5564cb059bb0c27 Mon Sep 17 00:00:00 2001 From: feive7 Date: Thu, 21 Aug 2025 11:10:13 -0700 Subject: [PATCH] Clamp camera pitch --- examples/core/core_3d_fps_controller.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/core/core_3d_fps_controller.c b/examples/core/core_3d_fps_controller.c index 68fec1af9..cd425a629 100644 --- a/examples/core/core_3d_fps_controller.c +++ b/examples/core/core_3d_fps_controller.c @@ -261,7 +261,9 @@ static void UpdateCameraAngle(Camera *camera) Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up)); // Rotate view vector around right axis - Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, -lookRotation.y - lean.y); + float pitchAngle = -player.body.lookRotation.y - player.lean.y; + pitchAngle = Clamp(pitchAngle, -PI / 2 + 0.0001f, PI / 2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down + Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle); // Head animation // Rotate up direction around forward axis