Added translation to leaning

This commit is contained in:
Franklin Blanco 2023-09-17 18:18:15 -07:00
parent 7783c4a165
commit 3573156316
3 changed files with 11 additions and 4 deletions

View File

@ -116,22 +116,32 @@ pub fn follow_cursor_with_camera(
Quat::from_axis_angle(Vec3::Y, yaw) * Quat::from_axis_angle(Vec3::X, pitch);
for mut camera_transform in camera_query.iter_mut() {
let local_z = camera_transform.local_z();
let right = Vec3::new(local_z.z * 0.5, camera_transform.translation.y, -local_z.x * 0.5);
player_transform.rotation = desired_rotation_quat;
if keyboard_input.pressed(KeyCode::Q) {
let final_quat = Quat::from_axis_angle(Vec3::Z, radians_from_degrees(30.0));
camera_transform.rotation = camera_transform
.rotation
.lerp(final_quat, time.delta_seconds() / 0.2);
camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: -right.x, y: camera_transform.translation.y, z: -right.z }, time.delta_seconds() / 0.2);
} else if keyboard_input.pressed(KeyCode::E) {
let final_quat =
Quat::from_axis_angle(Vec3::Z, radians_from_degrees(-30.0));
camera_transform.rotation = camera_transform
.rotation
.lerp(final_quat, time.delta_seconds() / 0.2);
camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: right.x, y: camera_transform.translation.y, z: right.z }, time.delta_seconds() / 0.2);
} else {
camera_transform.rotation = camera_transform
.rotation
.lerp(Quat::default(), time.delta_seconds() / 0.2);
camera_transform.translation = camera_transform.translation.lerp(Vec3 {
x: 0.0,
y: camera_transform.translation.y,
z: 0.0,
}, time.delta_seconds() / 0.2);
}
// headbob_camera(&mut camera_transform, time.delta_seconds_f64());
}

View File

@ -28,7 +28,7 @@ pub fn capture_hand_usage(
for mut hand_transform in hand_query.iter_mut() {
if player_firing_info.is_reloading {
for mut player in &mut players {
for player in &mut players {
if let Some(reload_animation) = animation_clips.get(&animations.reload_magazine) {
if player.elapsed() >= reload_animation.duration() {
magazine_data.rounds_shot = 0;
@ -45,7 +45,6 @@ pub fn capture_hand_usage(
}
// Set is_reloading = true
// At the end of reload animation, set magazine data to capacity = 0
}
// AIMING IN/OUT
if mouse_buttons.pressed(MouseButton::Right) {

View File

@ -43,6 +43,4 @@ pub fn load_scene(application: &mut App) {
application.add_systems(Update, capture_hand_usage);
application.add_systems(Startup, setup_lighting);
//application.add_systems(Update, setup_scene_once_loaded);
//application.add_systems(Update, play_animation);
}