mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-05 19:08:13 +00:00
Clamp camera pitch
This commit is contained in:
@@ -261,7 +261,9 @@ static void UpdateCameraAngle(Camera *camera)
|
|||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
|
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
|
||||||
|
|
||||||
// Rotate view vector around right axis
|
// 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
|
// Head animation
|
||||||
// Rotate up direction around forward axis
|
// Rotate up direction around forward axis
|
||||||
|
Reference in New Issue
Block a user