Clamp camera pitch between -85 and 85 degrees
This commit is contained in:
parent
9554f3ba7f
commit
4f4f3bced1
|
@ -223,8 +223,10 @@ impl CameraController {
|
||||||
|
|
||||||
// Apply rotation
|
// Apply rotation
|
||||||
let cam_ms = (self.move_speed * self.move_speed).to_radians() * dt;
|
let cam_ms = (self.move_speed * self.move_speed).to_radians() * dt;
|
||||||
|
let max_pitch = 85_f32.to_radians();
|
||||||
self.camera.yaw += cam_ms * self.rot_dirs_pressed.x as f32;
|
self.camera.yaw += cam_ms * self.rot_dirs_pressed.x as f32;
|
||||||
self.camera.pitch += cam_ms * self.rot_dirs_pressed.y as f32;
|
self.camera.pitch += cam_ms * self.rot_dirs_pressed.y as f32;
|
||||||
|
self.camera.pitch = self.camera.pitch.clamp(-max_pitch, max_pitch);
|
||||||
|
|
||||||
// Debug log
|
// Debug log
|
||||||
// log::info!("Camera Front: {:?}", front);
|
// log::info!("Camera Front: {:?}", front);
|
||||||
|
|
Loading…
Reference in New Issue