Gun colliding with ground and going into low ready && With introduction of floor collision groups now bullets go through floors

This commit is contained in:
Franklin 2023-11-26 17:22:05 -04:00
parent f05cee114b
commit 087420fb28
7 changed files with 16 additions and 13 deletions

View File

@ -37,7 +37,7 @@ Multiplayer
- [x] Gun colliding with bullet, making it lower on every shot fired. - [x] Gun colliding with bullet, making it lower on every shot fired.
- [x] Optics - [x] Optics
- [x] 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
- [ ] 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 - [ ] Weapon Clipping
- [ ] Make the player's collider bigger towards the front - [ ] Make the player's collider bigger towards the front
- [ ] Make the weapon's collider cover the firing point - [ ] 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] 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 drops on only one side of player
- [x] Gun dropping does not apply impulse for some reason... - [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 # Design

Binary file not shown.

View File

@ -93,10 +93,9 @@ pub fn drop_slot_in_game_world(
let mut drop_position = Transform::from_translation( let mut drop_position = Transform::from_translation(
player_transform.translation player_transform.translation
+ player_transform.up() * 5.0 + player_transform.up() * 5.0
+ player_transform.forward() * 5.0 + player_transform.forward() * 2.0
); );
drop_position.rotation = player_transform.rotation; 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_y(-90.0f32.to_radians());
drop_position.rotate_x(45.0f32.to_radians()); drop_position.rotate_x(45.0f32.to_radians());
drop_position.rotate_z(45.0f32.to_radians()); drop_position.rotate_z(45.0f32.to_radians());

View File

@ -12,6 +12,8 @@ bitflags! {
const SOLIDS = 0b00000100; const SOLIDS = 0b00000100;
const PLAYER = 0b00001000; const PLAYER = 0b00001000;
const FLOOR = 0b00010000;
const ALL = u32::MAX; const ALL = u32::MAX;
const NONE = 0; const NONE = 0;
} }

View File

@ -1,6 +1,5 @@
use crate::comps::core::{markers::{bullet::BulletMarker, muzzle_flash::MuzzleFlashMarker}, events::{bullet_collision::BulletCollisionEvent, collision_event_type::CollisionEventType}}; use crate::comps::core::{markers::{bullet::BulletMarker, muzzle_flash::MuzzleFlashMarker}, events::{bullet_collision::BulletCollisionEvent, collision_event_type::CollisionEventType}};
use bevy::prelude::*; use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
pub fn despawn_muzzle_flashes( pub fn despawn_muzzle_flashes(
mut commands: Commands, mut commands: Commands,
@ -29,7 +28,7 @@ pub fn despawn_stray_bullets(
match event.collision_type { match event.collision_type {
CollisionEventType::Start => { CollisionEventType::Start => {
commands.entity(event.bullet).remove::<Collider>(); //commands.entity(event.bullet).remove::<Collider>();
//commands.entity(bullet_entity).insert(Sensor); //commands.entity(bullet_entity).insert(Sensor);
spawn_bullet_hit_marker( spawn_bullet_hit_marker(
&mut commands, &mut commands,
@ -39,13 +38,12 @@ pub fn despawn_stray_bullets(
); );
}, },
CollisionEventType::End => { CollisionEventType::End => {
for (bullet, bullet_entity, _) in query.iter() { /*for (_, bullet_entity, _) in query.iter() {
if bullet_entity != event.bullet { continue; } if bullet_entity != event.bullet { continue; }
println!("Happened"); /*commands
commands
.entity(event.bullet) .entity(event.bullet)
.insert(Collider::ball(bullet.caliber.size())); .insert(Collider::ball(bullet.caliber.size()));*/
} }*/
//commands.entity(bullet_entity).remove::<Sensor>(); //commands.entity(bullet_entity).remove::<Sensor>();
//commands.entity(*entity_b).despawn(); //commands.entity(*entity_b).despawn();

View File

@ -127,8 +127,7 @@ pub fn spawn_bullet(
torque_impulse: Vec3::ZERO, torque_impulse: Vec3::ZERO,
}, },
ActiveEvents::COLLISION_EVENTS, 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(), Ccd::enabled(),
)); ));
} }

View File

@ -1,6 +1,8 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_rapier3d::prelude::*; use bevy_rapier3d::prelude::*;
use crate::comps::core::markers::collider_flags::ColliderFlags;
pub fn spawn_ground( pub fn spawn_ground(
mut commands: Commands, mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
@ -18,5 +20,6 @@ pub fn spawn_ground(
..default() ..default()
}), }),
..default() ..default()
}); })
.insert(CollisionGroups::new(Group::from_bits_retain(ColliderFlags::FLOOR.bits()), Group::from_bits_retain(ColliderFlags::ALL.bits())));
} }