All optics implementing a fn/trait that gives a specific gun offset to use the optic correctly
This commit is contained in:
parent
f78d4c7f40
commit
c1cd45192d
@ -34,9 +34,9 @@ Multiplayer
|
|||||||
- [x] EventCollision system that takes into account more than one type of collider.
|
- [x] EventCollision system that takes into account more than one type of collider.
|
||||||
- [x] Auto Low ready when gun collider hits object OR when player starts sprinting
|
- [x] Auto Low ready when gun collider hits object OR when player starts sprinting
|
||||||
- [ ] (Not a priority) Collision with wall and attempting to Aim can look very twitchy, maybe add a cooldown of 0.1-0.4s on each change from low ready to high ready
|
- [ ] (Not a priority) Collision with wall and attempting to Aim can look very twitchy, maybe add a cooldown of 0.1-0.4s on each change from low ready to high ready
|
||||||
- [ ] Optics
|
- [x] Optics
|
||||||
- [ ] All optics implementing a fn/trait that gives a specific gun offset to use the optic correctly
|
- [x] All optics implementing a fn/trait that gives a specific gun offset to use the optic correctly
|
||||||
- [ ] Find some way to implement a shader for the optics
|
- [ ] TODO: Find some way to implement a shader for the optics
|
||||||
- [ ] Bobbing
|
- [ ] Bobbing
|
||||||
- [ ] Gun Bob on run
|
- [ ] Gun Bob on run
|
||||||
- [ ] Gun Bob on walk
|
- [ ] Gun Bob on walk
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use bevy::{reflect::{Reflect, std_traits::ReflectDefault}, ecs::{component::Component, reflect::ReflectComponent}};
|
use bevy::{reflect::{Reflect, std_traits::ReflectDefault}, ecs::{component::Component, reflect::ReflectComponent}, math::Vec3};
|
||||||
|
|
||||||
use super::attachment::Attachment;
|
use super::attachment::Attachment;
|
||||||
|
|
||||||
@ -10,6 +10,14 @@ pub enum Optic {
|
|||||||
AimpointT1,
|
AimpointT1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Optic {
|
||||||
|
pub fn aimed_in_gun_pos_offset(&self) -> Vec3 {
|
||||||
|
match self {
|
||||||
|
Optic::AimpointT1 => Vec3 { x: 0.0, y: -0.05, z: 0.0 },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Attachment for Optic {
|
impl Attachment for Optic {
|
||||||
fn current_attachment_index(&self) -> u32 {
|
fn current_attachment_index(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
@ -20,4 +28,5 @@ impl Attachment for Optic {
|
|||||||
fn all_attachments() -> Vec<Self> where Self: Sized {
|
fn all_attachments() -> Vec<Self> where Self: Sized {
|
||||||
Vec::from([Self::AimpointT1])
|
Vec::from([Self::AimpointT1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,19 +37,15 @@ impl FirearmState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
pub fn get_optic_offset(&self) -> Vec3 {
|
||||||
Some(add) => {
|
for attachment_slot in self.attachment_slots.iter() {
|
||||||
let add_by = if add { 1 } else { -1 };
|
if attachment_slot.slot_type == WeaponSlot::SightSlot {
|
||||||
match attachment_slot.attachment {
|
if let Some(WeaponAttachment::Optic(optic)) = &attachment_slot.attachment {
|
||||||
Some(attachment) => ,
|
return optic.aimed_in_gun_pos_offset()
|
||||||
None => { // This means there was no attachment there. pass -1 to the from_index() fn. It will return the last one
|
}
|
||||||
|
}
|
||||||
},
|
}
|
||||||
}
|
Vec3::ZERO
|
||||||
},
|
}
|
||||||
None => {
|
}
|
||||||
attachment_slot.attachment = None;
|
|
||||||
},
|
|
||||||
*/
|
|
@ -196,8 +196,9 @@ pub fn capture_hand_usage(
|
|||||||
firearm_data.rebound_time_seconds
|
firearm_data.rebound_time_seconds
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if resources.mouse_buttons.pressed(MouseButton::Right)
|
if resources.mouse_buttons.pressed(MouseButton::Right) // Aiming in (RClick)
|
||||||
&& !resources.game_ui_state.any_window() && !player_linear_xz_state.is_sprinting() && !player_firing_info.gun_colliding_with_object
|
&& !resources.game_ui_state.any_window() && !player_linear_xz_state.is_sprinting()
|
||||||
|
&& !player_firing_info.gun_colliding_with_object
|
||||||
{
|
{
|
||||||
player_firing_info.gun_ready_pose = GunReadyPose::HighReady;
|
player_firing_info.gun_ready_pose = GunReadyPose::HighReady;
|
||||||
let rotation_lerp_quat = in_hand_transform.rotation.lerp(
|
let rotation_lerp_quat = in_hand_transform.rotation.lerp(
|
||||||
@ -207,7 +208,7 @@ pub fn capture_hand_usage(
|
|||||||
.clamp(0.0, 1.0),
|
.clamp(0.0, 1.0),
|
||||||
);
|
);
|
||||||
let position_lerp_vec3 = in_hand_transform.translation.lerp(
|
let position_lerp_vec3 = in_hand_transform.translation.lerp(
|
||||||
firearm_data.final_aimed_position + resources.player_settings.pos_aimed_offset,
|
firearm_data.final_aimed_position + resources.player_settings.pos_aimed_offset + firearm_state.get_optic_offset(),
|
||||||
(resources.time.delta_seconds()
|
(resources.time.delta_seconds()
|
||||||
/ lerp_time)
|
/ lerp_time)
|
||||||
.clamp(0.0, 1.0),
|
.clamp(0.0, 1.0),
|
||||||
@ -230,7 +231,7 @@ pub fn capture_hand_usage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SHOOTING & RECOIL
|
// SHOOTING & RECOIL
|
||||||
if resources.mouse_buttons.pressed(MouseButton::Left)
|
if resources.mouse_buttons.pressed(MouseButton::Left) // Shooting (LClick)
|
||||||
&& !resources.game_ui_state.any_window() && player_firing_info.gun_ready_pose == GunReadyPose::HighReady
|
&& !resources.game_ui_state.any_window() && player_firing_info.gun_ready_pose == GunReadyPose::HighReady
|
||||||
{
|
{
|
||||||
if let Some(magazine_data) = &mut firearm_state.magazine_data {
|
if let Some(magazine_data) = &mut firearm_state.magazine_data {
|
||||||
|
Loading…
Reference in New Issue
Block a user