Updated to continue on other machine
This commit is contained in:
parent
4f5b98a35f
commit
d40c2546e2
Binary file not shown.
|
@ -0,0 +1,36 @@
|
||||||
|
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: ,
|
||||||
|
transform: todo!(),
|
||||||
|
global_transform: todo!(),
|
||||||
|
visibility: todo!(),
|
||||||
|
computed_visibility: todo!(),
|
||||||
|
}).id()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod holdable;
|
|
@ -2,3 +2,6 @@ use bevy::prelude::Component;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Player;
|
pub struct Player;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct PlayerHand;
|
|
@ -1,3 +1,4 @@
|
||||||
pub mod camera;
|
pub mod camera;
|
||||||
pub mod controller;
|
pub mod controller;
|
||||||
pub mod markers;
|
pub mod markers;
|
||||||
|
pub mod holdable;
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod ar_15_rifle;
|
|
@ -1 +1,2 @@
|
||||||
pub mod core;
|
pub mod core;
|
||||||
|
pub mod guns;
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -3,3 +3,4 @@ pub mod camera_player_sync;
|
||||||
pub mod player_movement;
|
pub mod player_movement;
|
||||||
pub mod player_vertical_sync;
|
pub mod player_vertical_sync;
|
||||||
pub mod spawn_player;
|
pub mod spawn_player;
|
||||||
|
pub mod hands;
|
|
@ -2,11 +2,11 @@ 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},
|
comps::core::{camera::MainCamera, markers::player::{Player, PlayerHand}},
|
||||||
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,
|
||||||
},
|
},
|
||||||
scenes::scene1::skybox::{Cubemap, CUBEMAPS},
|
scenes::scene1::skybox::{Cubemap, CUBEMAPS}, utils,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::player_movement::{PlayerLinearXZState, PlayerLinearYState};
|
use super::player_movement::{PlayerLinearXZState, PlayerLinearYState};
|
||||||
|
@ -14,13 +14,32 @@ use super::player_movement::{PlayerLinearXZState, PlayerLinearYState};
|
||||||
pub fn spawn_player(mut commands: Commands, asset_server: Res<AssetServer>) {
|
pub fn spawn_player(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let skybox_handle = asset_server.load(CUBEMAPS[0].0);
|
let skybox_handle = asset_server.load(CUBEMAPS[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));
|
||||||
|
let ar_15 = commands.spawn(SceneBundle {
|
||||||
|
scene: asset_server.load("weapons/ar_15_rifle_base.glb#Scene0"),
|
||||||
|
visibility: Visibility::Inherited,
|
||||||
|
transform: ar_15_transform,
|
||||||
|
..default()
|
||||||
|
},).id();
|
||||||
|
|
||||||
|
let player_hand = commands.spawn(PlayerHand).insert(TransformBundle::from(Transform::from_xyz(1.0, -0.25, -3.0))).insert(VisibilityBundle {
|
||||||
|
visibility: Visibility::Inherited,
|
||||||
|
..Default::default()
|
||||||
|
}).push_children(&[ar_15]).id();
|
||||||
|
|
||||||
let camera = commands
|
let camera = commands
|
||||||
.spawn(MainCamera)
|
.spawn(MainCamera)
|
||||||
.insert(Camera3dBundle {
|
.insert(Camera3dBundle {
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
transform: Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(Skybox(skybox_handle.clone())).id();
|
.insert(Skybox(skybox_handle.clone()))
|
||||||
|
.insert(VisibilityBundle {
|
||||||
|
visibility: Visibility::Inherited,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.push_children(&[player_hand]).id();
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn(Player)
|
.spawn(Player)
|
||||||
|
@ -53,6 +72,10 @@ pub fn spawn_player(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
})
|
})
|
||||||
.insert(PlayerLinearYState::Falling)
|
.insert(PlayerLinearYState::Falling)
|
||||||
.insert(PlayerLinearXZState::Stopped)
|
.insert(PlayerLinearXZState::Stopped)
|
||||||
|
.insert(VisibilityBundle {
|
||||||
|
visibility: Visibility::Visible,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
.push_children(&[camera]);
|
.push_children(&[camera]);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ pub fn spawn_obstacles(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
|
asset_server: Res<AssetServer>
|
||||||
) {
|
) {
|
||||||
let box_1_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
let box_1_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
||||||
let box_2_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
let box_2_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
||||||
|
|
Loading…
Reference in New Issue