Fixed snapping back from leaning being too fast
This commit is contained in:
parent
7f8f9bc5ac
commit
6806fcc5b4
|
@ -17,13 +17,14 @@ Make sure guns are usable with iron sights.
|
|||
Multiplayer
|
||||
|
||||
# TODOs:
|
||||
- [ ] Detach player rotation from character model
|
||||
- [x] Detach player rotation from character model
|
||||
- [ ] Weapon Sway
|
||||
- [ ] Fixing leaning
|
||||
- [ ] Snap back leaning too quick
|
||||
- [ ] Bring Crouching back
|
||||
- [ ] Inspect animation (procedural)
|
||||
- [ ] Reload animation (procedural)
|
||||
- [ ] Real world magazines
|
||||
- [ ] Real world magazines
|
||||
- [ ] Rewriting bullet physics to use raycasts & kinematic rigidbodies (logic controlled)
|
||||
- [ ] Low Ready & High ready (low ready == more speed | high ready == more accuracy)
|
||||
- [ ] Auto Low ready when gun collider hits object OR when player starts sprinting
|
||||
|
|
|
@ -4,7 +4,6 @@ use bevy::{input::mouse::MouseMotion, prelude::*, window::CursorGrabMode};
|
|||
use crate::{
|
||||
comps::core::markers::{camera::MainCamera, player::Player},
|
||||
ui::game::game_ui_state::{GameUiState, GameUiWindow},
|
||||
utils::rad_deg::radians_from_degrees,
|
||||
};
|
||||
|
||||
use super::{player_movement::PlayerLinearXZState, player_values_state::PlayerValuesState};
|
||||
|
@ -156,8 +155,8 @@ pub fn follow_cursor_with_camera(
|
|||
|
||||
let desired_rotation_quat_player = Quat::from_axis_angle(Vec3::Y, yaw) * -1. ;
|
||||
|
||||
let local_z = camera_transform.local_z();
|
||||
let right = Vec3::new(local_z.z, camera_transform.translation.y, -local_z.x);
|
||||
//let local_z = camera_transform.local_z();
|
||||
//let right = Vec3::new(local_z.z, camera_transform.translation.y, -local_z.x);
|
||||
camera_transform.rotation = desired_rotation_quat_camera;
|
||||
if keyboard_input.pressed(KeyCode::Q) {
|
||||
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
||||
|
@ -168,14 +167,6 @@ pub fn follow_cursor_with_camera(
|
|||
).to_euler(EulerRot::XYZ);
|
||||
new_rot.1 = eulers.1;
|
||||
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
||||
/*player_transform.translation = player_transform.translation.lerp(
|
||||
Vec3 {
|
||||
x: -right.x,
|
||||
y: player_transform.translation.y,
|
||||
z: -right.z,
|
||||
},
|
||||
time.delta_seconds() / player_values_state.player_lean_time,
|
||||
);*/
|
||||
} else if keyboard_input.pressed(KeyCode::E) {
|
||||
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
||||
eulers.2 = eulers.2 + (player_values_state.player_lean_angle.to_radians() * -1.0);
|
||||
|
@ -186,16 +177,6 @@ pub fn follow_cursor_with_camera(
|
|||
new_rot.1 = eulers.1;
|
||||
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
||||
} else {
|
||||
/*camera_transform.rotation = camera_transform.rotation.lerp(
|
||||
Quat::default(),
|
||||
time.delta_seconds() / player_values_state.player_lean_time,
|
||||
);*/
|
||||
|
||||
/*let camera_rotation_to_follow: Vec3 = camera_transform.rotation.to_euler(EulerRot::XYZ).into(); // Move player Only on Y axis
|
||||
let mut original_rotation_in_euler: Vec3 = original_rotation.to_euler(EulerRot::XYZ).into();
|
||||
original_rotation_in_euler.y = camera_rotation_to_follow.y;
|
||||
|
||||
original_rotation = Quat::from_euler(EulerRot::XYZ, original_rotation_in_euler.x, original_rotation_in_euler.y, original_rotation_in_euler.z);*/
|
||||
|
||||
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
||||
eulers.2 = eulers.2 + 0.0f32.to_radians();
|
||||
|
@ -204,21 +185,7 @@ pub fn follow_cursor_with_camera(
|
|||
time.delta_seconds() / player_values_state.player_lean_time,
|
||||
).to_euler(EulerRot::XYZ);
|
||||
new_rot.1 = eulers.1;
|
||||
// TODO: fix fast snap rotation back to 0
|
||||
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
||||
player_transform.rotation = desired_rotation_quat_player;
|
||||
|
||||
//println!("Player EulerRot Y: {} Camera EulerRot Y: {}", player_transform.rotation.to_euler(EulerRot::XYZ).1, camera_transform.rotation.to_euler(EulerRot::XYZ).1);
|
||||
|
||||
//camera_transform.rotation = desired_rotation_quat;
|
||||
/*camera_transform.translation = camera_transform.translation.lerp(
|
||||
Vec3 {
|
||||
x: 0.0,
|
||||
y: camera_transform.translation.y,
|
||||
z: 0.0,
|
||||
},
|
||||
time.delta_seconds() / player_values_state.player_lean_time,
|
||||
);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue