From 930e075ad17fc55e47014399b343bc3ec214dfe9 Mon Sep 17 00:00:00 2001 From: scott-c Date: Fri, 6 Sep 2019 19:29:52 +0800 Subject: [PATCH] half camera height when rolling --- voxygen/src/scene/mod.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 96518f516b..81b7e7d039 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -124,14 +124,28 @@ impl Scene { .get(client.entity()) .map_or(Vec3::zero(), |pos| pos.0); + let player_rolling = client + .state() + .ecs() + .read_storage::() + .get(client.entity()) + .map_or(false, |cs| cs.movement.is_roll()); + // Alter camera position to match player. let tilt = self.camera.get_orientation().y; let dist = self.camera.get_distance(); - let up = if self.camera.get_mode() == CameraMode::FirstPerson { - 1.5 - } else { - 1.2 + + let up = match self.camera.get_mode() { + CameraMode::FirstPerson => { + if player_rolling { + 0.75 + } else { + 1.5 + } + } + CameraMode::ThirdPerson => 1.2, }; + self.camera.set_focus_pos( player_pos + Vec3::unit_z() * (up + dist * 0.15 - tilt.min(0.0) * dist * 0.75), );