From 087420fb2862dc155f842df2dc32a547f01840c8 Mon Sep 17 00:00:00 2001 From: Franklin Date: Sun, 26 Nov 2023 17:22:05 -0400 Subject: [PATCH] Gun colliding with ground and going into low ready && With introduction of floor collision groups now bullets go through floors --- Design.md | 4 +++- assets/weapons/ak105_rifle.glb | Bin 8228564 -> 8228564 bytes src/comps/core/inventory/player_inventory.rs | 3 +-- src/comps/core/markers/collider_flags.rs | 2 ++ src/logic/core/guns/despawn_shots.rs | 12 +++++------- src/logic/core/guns/shoot.rs | 3 +-- src/scenes/scene1/ground.rs | 5 ++++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Design.md b/Design.md index 8271a46..04ea6a9 100644 --- a/Design.md +++ b/Design.md @@ -37,7 +37,7 @@ Multiplayer - [x] Gun colliding with bullet, making it lower on every shot fired. - [x] Optics - [x] All optics implementing a fn/trait that gives a specific gun offset to use the optic correctly - - [ ] TODO: Find some way to implement a shader for the optics + - [ ] TODO: Find some way to implement a shader for the optics (AFTER IMPLEMENTING NEW BULLET SYSTEM) - [ ] Weapon Clipping - [ ] Make the player's collider bigger towards the front - [ ] Make the weapon's collider cover the firing point @@ -51,6 +51,8 @@ Multiplayer - [x] Create a Controls struct that holds mappings to all the game keys and replace them in all the game's code - [x] Gun dropping drops on only one side of player - [x] Gun dropping does not apply impulse for some reason... +- [ ] Gun colliding with ground and going into low ready +- [ ] With introduction of floor collision groups now bullets go through floors # Design diff --git a/assets/weapons/ak105_rifle.glb b/assets/weapons/ak105_rifle.glb index 439e9c97bface191553233a9d860df0f1870d85c..718a3dd40d68f9260d421109c041896ac71205c7 100644 GIT binary patch delta 520 zcmWl~$vPAO007|6APi;Smy(Qq&r;TC5KZ>2>}!lYEy$@u7dPkL!Oe?!7UzD4|NHO% zJ;dH~8xGt=f}uarz~5*fhR0)xBc3NDkVq0il1bqy&qyVWbTY^!i)?bpC69axD5QvD zN_fr-N_j~cuP7%(1(j4$O%1iwQBMPnG|@~8uW6-?b~<>&TRQ2Yn;v@U;~o7B@SZS( z3^B|HMi}KI5k4`-I1@}V#WXX_GRHg%eC7*_EV0ZAtE{ok2AgcL%?@ALWsfNP9B{}H b$DDA=H_rIZ4}S8Cb1t~#_gyq_wR`;^>BOGc delta 554 zcmWm2Syzk!0LJlSB1DTQTcjA0Y0NvzJMWMdElPz}wAu=YTW@EzRwBJ){X z_v<|8cb;?p0*$P@?jK|!YGVNdvW4doH)e6 zS8$jkRC1JK9H)vCoTQo>YN_KC^_=Dm4K#9=bDZY_7ir=Wmucn-Ewpl#Yb3eO4cfR# zJGV&DL7LlS2*{EnPl1pk5hd<$mrm}{MK?Y4a-Tl>8DNkH3^B|@Mi^y`M?B^U<4iEg z6w}P`lxI9=mO18GV38$W@RC=&<_*iN@RoPHC*}hm`NU_wu*w?iY_Q2!zVV$cw%K8q LAOGUS&-nK~lhUNz diff --git a/src/comps/core/inventory/player_inventory.rs b/src/comps/core/inventory/player_inventory.rs index 39e5d2b..137fa03 100644 --- a/src/comps/core/inventory/player_inventory.rs +++ b/src/comps/core/inventory/player_inventory.rs @@ -93,10 +93,9 @@ pub fn drop_slot_in_game_world( let mut drop_position = Transform::from_translation( player_transform.translation + player_transform.up() * 5.0 - + player_transform.forward() * 5.0 + + player_transform.forward() * 2.0 ); drop_position.rotation = player_transform.rotation; - //drop_position.rotate_y(90.0f32.to_radians()); drop_position.rotate_y(-90.0f32.to_radians()); drop_position.rotate_x(45.0f32.to_radians()); drop_position.rotate_z(45.0f32.to_radians()); diff --git a/src/comps/core/markers/collider_flags.rs b/src/comps/core/markers/collider_flags.rs index 49d3e18..e5dec92 100644 --- a/src/comps/core/markers/collider_flags.rs +++ b/src/comps/core/markers/collider_flags.rs @@ -12,6 +12,8 @@ bitflags! { const SOLIDS = 0b00000100; const PLAYER = 0b00001000; + const FLOOR = 0b00010000; + const ALL = u32::MAX; const NONE = 0; } diff --git a/src/logic/core/guns/despawn_shots.rs b/src/logic/core/guns/despawn_shots.rs index 715bdd8..48cf5b8 100644 --- a/src/logic/core/guns/despawn_shots.rs +++ b/src/logic/core/guns/despawn_shots.rs @@ -1,6 +1,5 @@ use crate::comps::core::{markers::{bullet::BulletMarker, muzzle_flash::MuzzleFlashMarker}, events::{bullet_collision::BulletCollisionEvent, collision_event_type::CollisionEventType}}; use bevy::prelude::*; -use bevy_rapier3d::prelude::*; pub fn despawn_muzzle_flashes( mut commands: Commands, @@ -29,7 +28,7 @@ pub fn despawn_stray_bullets( match event.collision_type { CollisionEventType::Start => { - commands.entity(event.bullet).remove::(); + //commands.entity(event.bullet).remove::(); //commands.entity(bullet_entity).insert(Sensor); spawn_bullet_hit_marker( &mut commands, @@ -39,13 +38,12 @@ pub fn despawn_stray_bullets( ); }, CollisionEventType::End => { - for (bullet, bullet_entity, _) in query.iter() { + /*for (_, bullet_entity, _) in query.iter() { if bullet_entity != event.bullet { continue; } - println!("Happened"); - commands + /*commands .entity(event.bullet) - .insert(Collider::ball(bullet.caliber.size())); - } + .insert(Collider::ball(bullet.caliber.size()));*/ + }*/ //commands.entity(bullet_entity).remove::(); //commands.entity(*entity_b).despawn(); diff --git a/src/logic/core/guns/shoot.rs b/src/logic/core/guns/shoot.rs index b2a7dd8..cb5269f 100644 --- a/src/logic/core/guns/shoot.rs +++ b/src/logic/core/guns/shoot.rs @@ -127,8 +127,7 @@ pub fn spawn_bullet( torque_impulse: Vec3::ZERO, }, ActiveEvents::COLLISION_EVENTS, - CollisionGroups::new(Group::from_bits_retain(ColliderFlags::BULLETS.bits()), Group::from_bits_retain(ColliderFlags::SOLIDS.bits())), + CollisionGroups::new(Group::from_bits_retain(ColliderFlags::BULLETS.bits()), Group::from_bits_retain((ColliderFlags::SOLIDS | ColliderFlags::FLOOR).bits())), Ccd::enabled(), - )); } diff --git a/src/scenes/scene1/ground.rs b/src/scenes/scene1/ground.rs index 201faf0..9eaca9d 100644 --- a/src/scenes/scene1/ground.rs +++ b/src/scenes/scene1/ground.rs @@ -1,6 +1,8 @@ use bevy::prelude::*; use bevy_rapier3d::prelude::*; +use crate::comps::core::markers::collider_flags::ColliderFlags; + pub fn spawn_ground( mut commands: Commands, mut meshes: ResMut>, @@ -18,5 +20,6 @@ pub fn spawn_ground( ..default() }), ..default() - }); + }) + .insert(CollisionGroups::new(Group::from_bits_retain(ColliderFlags::FLOOR.bits()), Group::from_bits_retain(ColliderFlags::ALL.bits()))); }