Removed not needed system and added impulse force to dropped guns

This commit is contained in:
Franklin 2023-11-14 16:22:54 -04:00
parent c55bb81fd7
commit 494e99a548
9 changed files with 35 additions and 36 deletions

View File

@ -1,11 +1,18 @@
# Experimental game
## Things to finish:
### - New Movement System
- [ ] Rotations and transforms are based on animations
- [ ] Camera is a child of the head
- [ ] Figure out how rotation up and down will work, maybe dividing upper and lower body animations
- [ ] Shuffling feet when rotating
- [ ] Perfect movement
- [x] Equipping items
- [x] Replace items in the same slot, drop them
- [ ] When equipping an item that replaces another item because of the slot, throw item towards front of player
- [x] ~~Equipping items~~
- [x] ~~Replace items in the same slot, drop them~~
- [x] When equipping an item that replaces another item because of the slot, throw item towards front of player with a specific impulse
- [ ] Gun aiming and noscope is not the same position
- [ ] Controls being bindable
- [ ] Gun moving out of the way on a collision
@ -14,6 +21,8 @@
- [ ] Persistent magazine data
- [ ] Perfectly center interact clue text on screen
- [ ] Fix: No Sprinting while aiming
- [x] ~~FIX: Gun spawning way in front of player~~
- [ ] Player is rotating on an axis that it shouldn't
- [ ] Fix: Make gun have more priority in rendering. So it doesn't clip through walls

View File

@ -33,6 +33,7 @@ pub trait Item: Sync + Send {
transform: Transform,
assets_gltf: &GltfAssets,
loaded_gltf_assets: &Assets<Gltf>,
with_impulse: Vec3,
) {
match self.get_type() {
ItemType::Holdable(object_type) => {
@ -89,6 +90,10 @@ pub trait Item: Sync + Send {
firearm_size.y,
firearm_size.z,
),
ExternalImpulse {
impulse: with_impulse,
..Default::default()
},
Interactable::Item(firearm.get_item_arc()),
))
.push_children(&[firearm_asset_entity]);

View File

@ -30,6 +30,7 @@ pub fn item_spawner(
component_sp.get_transform(),
&assets_gltf,
&loaded_gltf_assets,
Vec3::ZERO,
)
}
//m4.spawn(&mut commands, item_sp.at, &assets_gltf, &loaded_gltf_assets);

View File

@ -51,7 +51,7 @@ pub fn player_spawner(
let player_hand = commands
.spawn((PlayerHand, Name::new("Player Hand")))
.insert(TransformBundle::from(Transform::from_xyz(
0.6, -0.45, -20.0,
0.6, -0.45, 0.0,
)))
.insert(VisibilityBundle {
visibility: Visibility::Inherited,

View File

@ -5,16 +5,15 @@ use crate::{
comps::core::{
events::pickup_item::PickupItemEvent,
inventory::player_inventory::PlayerInventory,
items::item::ItemType,
markers::{
camera::MainCamera,
firearm::{FirearmData, MagazineData},
holdable::{HoldableObjectType, InPlayerHands},
holdable::InPlayerHands,
interactable::Interactable,
player::{Player, PlayerHand},
},
},
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo, shoot::shoot_bullet},
logic::core::guns::{player_firing::PlayerFiringInfo, shoot::shoot_bullet},
setup::{
animations::AllFirearmAnimations,
equipment::{Equipment, EquipmentChangeEvent},

View File

@ -29,6 +29,14 @@ pub fn update_player_inventory_system(
.entity(event.entity)
.despawn_descendants()
.despawn();
let drop_position = Transform::from_translation(
player_transform.translation
+ player_transform.up() * 3.0
+ player_transform.forward() * 2.0,
);
let drop_impulse = player_transform.translation
+ player_transform.up() * 100.0
+ player_transform.forward() * 30.0;
match firearm.firearm_data().firearm_type {
FirearmType::Primary => {
// Send equipment_changed_event
@ -36,13 +44,10 @@ pub fn update_player_inventory_system(
// Drop this one
primary_item.spawn(
&mut commands,
Transform::from_translation(
player_transform.translation
+ player_transform.up() * 5.0
+ player_transform.forward(),
),
drop_position,
&assets_gltf,
&loaded_gltf_assets,
drop_impulse,
);
player_inventory.primary.item =
Some(firearm.get_item_box())
@ -55,13 +60,10 @@ pub fn update_player_inventory_system(
if let Some(secondary) = player_inventory.get_secondary() {
secondary.spawn(
&mut commands,
Transform::from_translation(
player_transform.translation
+ player_transform.up() * 5.0
+ player_transform.forward(),
),
drop_position,
&assets_gltf,
&loaded_gltf_assets,
drop_impulse,
);
player_inventory.secondary.item =
Some(firearm.get_item_box())

View File

@ -26,7 +26,7 @@ use crate::{
};
use super::{
ground::spawn_ground, items::spawn_items, lighting::setup_lighting, obstacles::spawn_obstacles,
ground::spawn_ground, lighting::setup_lighting, obstacles::spawn_obstacles,
skybox::set_skybox_if_loaded, spawn_points::set_spawn_points,
};
@ -43,7 +43,7 @@ pub fn load_scene(application: &mut App) {
application.add_systems(Startup, spawn_ground);
application.add_systems(
Startup,
(spawn_obstacles, spawn_items.after(load_all_assets)),
spawn_obstacles,
);
application.add_systems(Startup, setup_lighting);
application.add_systems(Startup, set_spawn_points);

View File

@ -1,16 +0,0 @@
use bevy::{gltf::Gltf, prelude::*};
use crate::{
comps::core::items::{guns::m4a1::M4a1GunItem, item::Item},
setup::assets::GltfAssets,
};
pub fn spawn_items(
mut commands: Commands,
assets_gltf: Res<GltfAssets>,
loaded_gltf_assets: Res<Assets<Gltf>>,
) {
let transform = Transform::from_xyz(20.0, 1.0, 10.0);
let m4item = M4a1GunItem;
m4item.spawn(&mut commands, transform, &assets_gltf, &loaded_gltf_assets);
}

View File

@ -1,7 +1,6 @@
pub mod init;
pub mod ground;
pub mod items;
pub mod lighting;
pub mod obstacles;
pub mod skybox;