abc
This commit is contained in:
parent
84e38948e6
commit
7f8f9bc5ac
14
Design.md
14
Design.md
@ -16,13 +16,25 @@ Make sure guns are usable with iron sights.
|
|||||||
|
|
||||||
Multiplayer
|
Multiplayer
|
||||||
|
|
||||||
# TODOS:
|
# TODOs:
|
||||||
- [ ] Detach player rotation from character model
|
- [ ] Detach player rotation from character model
|
||||||
- [ ] Weapon Sway
|
- [ ] Weapon Sway
|
||||||
- [ ] Fixing leaning
|
- [ ] Fixing leaning
|
||||||
|
- [ ] 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
|
||||||
|
|
||||||
|
|
||||||
|
# Design
|
||||||
|
|
||||||
|
- Detach player rotation from character model
|
||||||
|
Don't parent the hands to the camera
|
||||||
|
Make the hands move to the camera with a delay + lerp
|
||||||
|
On player movement:
|
||||||
|
WASD -> Translate player parent objetc, everything else follows
|
||||||
|
Mouse movements -> Rotate camera (on all axises) + Player Character (Not parent object) on only the horizontal axis (Z I think)
|
||||||
|
What moves first is the camera, then the entire body moves with a lerp
|
@ -123,7 +123,10 @@ pub fn follow_cursor_with_camera(
|
|||||||
|
|
||||||
if window.cursor.grab_mode != CursorGrabMode::None {
|
if window.cursor.grab_mode != CursorGrabMode::None {
|
||||||
for mut player_transform in player_query.iter_mut() {
|
for mut player_transform in player_query.iter_mut() {
|
||||||
let (mut yaw, mut pitch, _) = player_transform.rotation.to_euler(EulerRot::YXZ);
|
|
||||||
|
|
||||||
|
for mut camera_transform in camera_query.iter_mut() {
|
||||||
|
let (mut yaw, mut pitch) = (player_transform.rotation.to_euler(EulerRot::YXZ).0, camera_transform.rotation.to_euler(EulerRot::YXZ).1) ;
|
||||||
for motion in motions.read() {
|
for motion in motions.read() {
|
||||||
let window_scale = window.height().min(window.width());
|
let window_scale = window.height().min(window.width());
|
||||||
if btn.pressed(MouseButton::Right) {
|
if btn.pressed(MouseButton::Right) {
|
||||||
@ -148,61 +151,74 @@ pub fn follow_cursor_with_camera(
|
|||||||
}
|
}
|
||||||
pitch = pitch.clamp(-1.54, 1.54);
|
pitch = pitch.clamp(-1.54, 1.54);
|
||||||
|
|
||||||
let desired_rotation_quat =
|
let desired_rotation_quat_camera =
|
||||||
(Quat::from_axis_angle(Vec3::Y, yaw) * -1. )* Quat::from_axis_angle(Vec3::X, pitch);
|
Quat::from_axis_angle(Vec3::X, pitch);
|
||||||
|
|
||||||
|
let desired_rotation_quat_player = Quat::from_axis_angle(Vec3::Y, yaw) * -1. ;
|
||||||
|
|
||||||
for mut camera_transform in camera_query.iter_mut() {
|
|
||||||
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);
|
||||||
player_transform.rotation = desired_rotation_quat;
|
camera_transform.rotation = desired_rotation_quat_camera;
|
||||||
if keyboard_input.pressed(KeyCode::Q) {
|
if keyboard_input.pressed(KeyCode::Q) {
|
||||||
let final_quat = Quat::from_axis_angle(
|
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
||||||
Vec3::Z,
|
eulers.2 = eulers.2 + player_values_state.player_lean_angle.to_radians();
|
||||||
radians_from_degrees(player_values_state.player_lean_angle),
|
let mut new_rot = player_transform.rotation.lerp(
|
||||||
);
|
Quat::from_euler(EulerRot::XYZ, eulers.0, eulers.1, eulers.2),
|
||||||
camera_transform.rotation = camera_transform.rotation.lerp(
|
|
||||||
final_quat,
|
|
||||||
time.delta_seconds() / player_values_state.player_lean_time,
|
time.delta_seconds() / player_values_state.player_lean_time,
|
||||||
);
|
).to_euler(EulerRot::XYZ);
|
||||||
camera_transform.translation = camera_transform.translation.lerp(
|
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 {
|
Vec3 {
|
||||||
x: -right.x,
|
x: -right.x,
|
||||||
y: camera_transform.translation.y,
|
y: player_transform.translation.y,
|
||||||
z: -right.z,
|
z: -right.z,
|
||||||
},
|
},
|
||||||
time.delta_seconds() / player_values_state.player_lean_time,
|
time.delta_seconds() / player_values_state.player_lean_time,
|
||||||
);
|
);*/
|
||||||
} else if keyboard_input.pressed(KeyCode::E) {
|
} else if keyboard_input.pressed(KeyCode::E) {
|
||||||
let final_quat = Quat::from_axis_angle(
|
let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ);
|
||||||
Vec3::Z,
|
eulers.2 = eulers.2 + (player_values_state.player_lean_angle.to_radians() * -1.0);
|
||||||
radians_from_degrees(-player_values_state.player_lean_angle),
|
let mut new_rot = player_transform.rotation.lerp(
|
||||||
);
|
Quat::from_euler(EulerRot::XYZ, eulers.0, eulers.1, eulers.2),
|
||||||
camera_transform.rotation = camera_transform.rotation.lerp(
|
|
||||||
final_quat,
|
|
||||||
time.delta_seconds() / player_values_state.player_lean_time,
|
time.delta_seconds() / player_values_state.player_lean_time,
|
||||||
);
|
).to_euler(EulerRot::XYZ);
|
||||||
camera_transform.translation = camera_transform.translation.lerp(
|
new_rot.1 = eulers.1;
|
||||||
Vec3 {
|
player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2);
|
||||||
x: right.x,
|
|
||||||
y: camera_transform.translation.y,
|
|
||||||
z: right.z,
|
|
||||||
},
|
|
||||||
time.delta_seconds() / player_values_state.player_lean_time,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
camera_transform.rotation = camera_transform.rotation.lerp(
|
/*camera_transform.rotation = camera_transform.rotation.lerp(
|
||||||
Quat::default(),
|
Quat::default(),
|
||||||
time.delta_seconds() / player_values_state.player_lean_time,
|
time.delta_seconds() / player_values_state.player_lean_time,
|
||||||
);
|
);*/
|
||||||
|
|
||||||
camera_transform.translation = camera_transform.translation.lerp(
|
/*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();
|
||||||
|
let mut new_rot = player_transform.rotation.lerp(
|
||||||
|
Quat::from_euler(EulerRot::XYZ, eulers.0, eulers.1, eulers.2),
|
||||||
|
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 {
|
Vec3 {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
y: camera_transform.translation.y,
|
y: camera_transform.translation.y,
|
||||||
z: 0.0,
|
z: 0.0,
|
||||||
},
|
},
|
||||||
time.delta_seconds() / player_values_state.player_lean_time,
|
time.delta_seconds() / player_values_state.player_lean_time,
|
||||||
);
|
);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ fn setup_plugins(application: &mut App) {
|
|||||||
.add_plugins(DefaultPlugins.set(AssetPlugin::default()))
|
.add_plugins(DefaultPlugins.set(AssetPlugin::default()))
|
||||||
//.add_plugins(DefaultInspectorConfigPlugin)
|
//.add_plugins(DefaultInspectorConfigPlugin)
|
||||||
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
|
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
|
||||||
.add_plugins(RapierDebugRenderPlugin::default())
|
//.add_plugins(RapierDebugRenderPlugin::default())
|
||||||
.add_plugins(ComponentsFromGltfPlugin)
|
.add_plugins(ComponentsFromGltfPlugin)
|
||||||
//.add_plugins(bevy_egui::EguiPlugin)
|
//.add_plugins(bevy_egui::EguiPlugin)
|
||||||
//.add_plugins(WorldInspectorPlugin::new())
|
//.add_plugins(WorldInspectorPlugin::new())
|
||||||
|
Loading…
Reference in New Issue
Block a user