Added holdable marker struct and moved things around
This commit is contained in:
parent
3eeff6b11a
commit
5e7f1407f0
Binary file not shown.
@ -1,35 +0,0 @@
|
|||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
use bevy::gltf::Gltf;
|
|
||||||
|
|
||||||
#[derive(Resource)]
|
|
||||||
pub struct LoadedAsset(Handle<Gltf>);
|
|
||||||
|
|
||||||
fn load_gltf(
|
|
||||||
mut commands: Commands,
|
|
||||||
ass: Res<AssetServer>,
|
|
||||||
) {
|
|
||||||
let gltf = ass.load("my_asset_pack.glb");
|
|
||||||
commands.insert_resource(LoadedAsset(gltf));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Anything that can go in the player's hands.
|
|
||||||
pub struct HoldableObject {
|
|
||||||
pub transform: Transform,
|
|
||||||
/// Initial Rotation in degrees
|
|
||||||
pub y_rot: f32,
|
|
||||||
pub asset_handle: Handle<Gltf>,
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HoldableObject {
|
|
||||||
pub fn spawn_in_world(&mut self, mut commands: Commands) -> Entity {
|
|
||||||
commands.spawn(SceneBundle {
|
|
||||||
scene: todo!(),
|
|
||||||
transform: todo!(),
|
|
||||||
global_transform: todo!(),
|
|
||||||
visibility: todo!(),
|
|
||||||
computed_visibility: todo!(),
|
|
||||||
}).id()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
pub mod holdable;
|
|
10
src/comps/core/markers/holdable.rs
Normal file
10
src/comps/core/markers/holdable.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Anything that can go in the player's hands.
|
||||||
|
#[derive(Component, Default, Debug)]
|
||||||
|
pub struct HoldableObject {
|
||||||
|
/// Where this object should be placed relative to the hand.
|
||||||
|
pub held_at: Vec3,
|
||||||
|
/// Initial Rotation in degrees
|
||||||
|
pub y_rot: f32,
|
||||||
|
}
|
@ -1 +1,3 @@
|
|||||||
pub mod player;
|
pub mod player;
|
||||||
|
pub mod holdable;
|
||||||
|
pub mod camera;
|
@ -1,4 +1,2 @@
|
|||||||
pub mod camera;
|
|
||||||
pub mod controller;
|
pub mod controller;
|
||||||
pub mod markers;
|
pub mod markers;
|
||||||
pub mod holdable;
|
|
@ -2,7 +2,7 @@ use bevy::{input::mouse::MouseMotion, prelude::*};
|
|||||||
//use bevy_rapier3d::prelude::*;
|
//use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comps::core::{camera::MainCamera, markers::player::Player},
|
comps::core::markers::{player::Player, camera::MainCamera},
|
||||||
constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT, PLAYER_CROUCH_TIME_MS},
|
constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT, PLAYER_CROUCH_TIME_MS},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use bevy::{core_pipeline::Skybox, prelude::*};
|
|||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comps::core::{camera::MainCamera, markers::player::{Player, PlayerHand}},
|
comps::core::markers::{player::{Player, PlayerHand}, camera::MainCamera},
|
||||||
constants::player_values::{
|
constants::player_values::{
|
||||||
PLAYER_GRAVITY_SCALE, PLAYER_HEIGHT, PLAYER_INITIAL_WEIGHT, PLAYER_LINEAR_DAMPING,
|
PLAYER_GRAVITY_SCALE, PLAYER_HEIGHT, PLAYER_INITIAL_WEIGHT, PLAYER_LINEAR_DAMPING,
|
||||||
},
|
},
|
||||||
@ -17,7 +17,7 @@ pub fn spawn_player(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
let mut ar_15_transform = Transform::from_xyz(0.0, 0.0, 0.0);
|
let mut ar_15_transform = Transform::from_xyz(0.0, 0.0, 0.0);
|
||||||
ar_15_transform.rotate_y(utils::rad_deg::radians_from_degrees(-90.0));
|
ar_15_transform.rotate_y(utils::rad_deg::radians_from_degrees(-90.0));
|
||||||
let ar_15 = commands.spawn(SceneBundle {
|
let ar_15 = commands.spawn(SceneBundle {
|
||||||
scene: asset_server.load("weapons/ar_15_rifle_base.glb#Scene0"),
|
scene: asset_server.load("weapons/m4a1_rifle.glb#Scene0"),
|
||||||
visibility: Visibility::Inherited,
|
visibility: Visibility::Inherited,
|
||||||
transform: ar_15_transform,
|
transform: ar_15_transform,
|
||||||
..default()
|
..default()
|
||||||
|
15
src/setup/gltf_assets.rs
Normal file
15
src/setup/gltf_assets.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use bevy::gltf::Gltf;
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct LoadedAsset(Handle<Gltf>);
|
||||||
|
|
||||||
|
/// Loads gltf asset into AssetServer. Inserts Resource as a LoadedAsset
|
||||||
|
pub fn load_gltf(
|
||||||
|
mut commands: Commands,
|
||||||
|
ass: Res<AssetServer>,
|
||||||
|
) {
|
||||||
|
let gltf = ass.load("my_asset_pack.glb");
|
||||||
|
commands.insert_resource(LoadedAsset(gltf));
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
|
|
||||||
|
pub mod gltf_assets;
|
Loading…
Reference in New Issue
Block a user