Ver código fonte

Clamp camera pitch

pull/5137/head
feive7 1 mês atrás
pai
commit
8b0cbb6f47
1 arquivos alterados com 3 adições e 1 exclusões
  1. +3
    -1
      examples/core/core_3d_fps_controller.c

+ 3
- 1
examples/core/core_3d_fps_controller.c Ver arquivo

@ -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

Carregando…
Cancelar
Salvar