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
|
Multiplayer
|
||||||
|
|
||||||
# TODOs:
|
# TODOs:
|
||||||
- [ ] Detach player rotation from character model
|
- [x] Detach player rotation from character model
|
||||||
- [ ] Weapon Sway
|
- [ ] Weapon Sway
|
||||||
- [ ] Fixing leaning
|
- [ ] Fixing leaning
|
||||||
|
- [ ] Snap back leaning too quick
|
||||||
- [ ] Bring Crouching back
|
- [ ] Bring Crouching back
|
||||||
- [ ] Inspect animation (procedural)
|
- [ ] Inspect animation (procedural)
|
||||||
- [ ] Reload animation (procedural)
|
- [ ] Reload animation (procedural)
|
||||||
- [ ] Real world magazines
|
- [ ] Real world magazines
|
||||||
- [ ] Rewriting bullet physics to use raycasts & kinematic rigidbodies (logic controlled)
|
- [ ] Rewriting bullet physics to use raycasts & kinematic rigidbodies (logic controlled)
|
||||||
- [ ] Low Ready & High ready (low ready == more speed | high ready == more accuracy)
|
- [ ] 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
|
- [ ] 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::{
|
use crate::{
|
||||||
comps::core::markers::{camera::MainCamera, player::Player},
|
comps::core::markers::{camera::MainCamera, player::Player},
|
||||||
ui::game::game_ui_state::{GameUiState, GameUiWindow},
|
ui::game::game_ui_state::{GameUiState, GameUiWindow},
|
||||||
utils::rad_deg::radians_from_degrees,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{player_movement::PlayerLinearXZState, player_values_state::PlayerValuesState};
|
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 desired_rotation_quat_player = Quat::from_axis_angle(Vec3::Y, yaw) * -1. ;
|
||||||
|
|
||||||
let local_z = camera_transform.local_z();
|
//let local_z = camera_transform.local_z();
|
||||||
let right = Vec3::new(local_z.z, camera_transform.translation.y, -local_z.x);
|
//let right = Vec3::new(local_z.z, camera_transform.translation.y, -local_z.x);
|
||||||
camera_transform.rotation = desired_rotation_quat_camera;
|
camera_transform.rotation = desired_rotation_quat_camera;
|
||||||
if keyboard_input.pressed(KeyCode::Q) {
|
if keyboard_input.pressed(KeyCode::Q) {
|
||||||
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
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);
|
).to_euler(EulerRot::XYZ);
|
||||||
new_rot.1 = eulers.1;
|
new_rot.1 = eulers.1;
|
||||||
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
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) {
|
} else if keyboard_input.pressed(KeyCode::E) {
|
||||||
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
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);
|
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;
|
new_rot.1 = eulers.1;
|
||||||
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
||||||
} else {
|
} 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);
|
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
||||||
eulers.2 = eulers.2 + 0.0f32.to_radians();
|
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,
|
time.delta_seconds() / player_values_state.player_lean_time,
|
||||||
).to_euler(EulerRot::XYZ);
|
).to_euler(EulerRot::XYZ);
|
||||||
new_rot.1 = eulers.1;
|
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 = 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
Block a user