diff --git a/assets/character/main_character.glb b/assets/character/main_character.glb index 0abb1ae..ba27c20 100644 Binary files a/assets/character/main_character.glb and b/assets/character/main_character.glb differ diff --git a/src/comps/core/markers/proxy/character/mod.rs b/src/comps/core/markers/proxy/character/mod.rs index 42c3b97..47d1673 100644 --- a/src/comps/core/markers/proxy/character/mod.rs +++ b/src/comps/core/markers/proxy/character/mod.rs @@ -1,4 +1,5 @@ pub mod player_character; pub mod player_hitbox; pub mod in_player_hands_parent; -pub mod player_eye; \ No newline at end of file +pub mod player_eye; +pub mod third_person_camera; \ No newline at end of file diff --git a/src/comps/core/markers/proxy/character/player_eye.rs b/src/comps/core/markers/proxy/character/player_eye.rs index 7ffca80..9e6a81f 100644 --- a/src/comps/core/markers/proxy/character/player_eye.rs +++ b/src/comps/core/markers/proxy/character/player_eye.rs @@ -3,6 +3,8 @@ use bevy_rapier3d::prelude::*; use crate::{comps::core::markers::{proxy::physics::rapier::LinkToPlayer, camera::MainCamera}, logic::core::player::player_values_state::PlayerValuesState}; +use super::third_person_camera::{ThirdPersonCameraProxy, ThirdPersonCamera}; + #[derive(Component, Reflect, Default, Debug)] #[reflect(Component)] @@ -11,6 +13,7 @@ pub struct PlayerEye; pub fn insert_components_into_spawned_player( mut commands: Commands, eye_query: Query>, + third_person_camera_query: Query>, player_collider_query: Query, With, Added)>, player_values_state: Res, ) { @@ -31,6 +34,29 @@ pub fn insert_components_into_spawned_player( .id(); commands.entity(eye).add_child(camera); } + for third_person_camera in third_person_camera_query.iter() { + + let mut cam_bundle = Camera3dBundle { + transform: Transform::from_translation(Vec3::ZERO), + ..Default::default() + }; + cam_bundle.camera.is_active = false; + cam_bundle.camera.order = 1; + + // Spawn camera + let camera = commands + .spawn(cam_bundle) + //s.insert(Skybox(skybox_handle.clone())) + .insert(VisibilityBundle { + visibility: Visibility::Inherited, + ..Default::default() + }) + .insert(ThirdPersonCamera) + //.push_children(&[player_hand]) + .id(); + commands.entity(third_person_camera).add_child(camera); + + } for entity in player_collider_query.iter() { commands.entity(entity) .insert(Restitution::coefficient(0.0)) diff --git a/src/comps/core/markers/proxy/character/third_person_camera.rs b/src/comps/core/markers/proxy/character/third_person_camera.rs new file mode 100644 index 0000000..8e1affb --- /dev/null +++ b/src/comps/core/markers/proxy/character/third_person_camera.rs @@ -0,0 +1,10 @@ +use bevy::prelude::*; + + +#[derive(Component, Reflect, Default, Debug)] +#[reflect(Component)] +pub struct ThirdPersonCameraProxy; + +#[derive(Component, Reflect, Default, Debug)] +#[reflect(Component)] +pub struct ThirdPersonCamera; \ No newline at end of file diff --git a/src/comps/core/markers/proxy/plugin.rs b/src/comps/core/markers/proxy/plugin.rs index e6b5803..30a1c5e 100644 --- a/src/comps/core/markers/proxy/plugin.rs +++ b/src/comps/core/markers/proxy/plugin.rs @@ -2,7 +2,7 @@ use bevy::app::{Plugin, Update}; use crate::setup::load_state::update_game_load_state; -use super::{character::{player_hitbox::PlayerHitBox, player_character::PlayerCharacter, player_eye::{PlayerEye, insert_components_into_spawned_player}, in_player_hands_parent::{InPlayerHandsParent, insert_components_into_player_hand}}, physics::{rapier::{AutoAABBCollider, physics_replace_proxies}, self}}; +use super::{character::{player_hitbox::PlayerHitBox, player_character::PlayerCharacter, player_eye::{PlayerEye, insert_components_into_spawned_player}, in_player_hands_parent::{InPlayerHandsParent, insert_components_into_player_hand}, third_person_camera::ThirdPersonCameraProxy}, physics::{rapier::{AutoAABBCollider, physics_replace_proxies}, self}}; @@ -18,6 +18,7 @@ impl Plugin for ProxyComponentsPlugin { app.register_type::(); app.register_type::(); app.register_type::(); + app.register_type::(); // Physics app.register_type::(); diff --git a/src/logic/core/player/animate_player.rs b/src/logic/core/player/animate_player.rs new file mode 100644 index 0000000..15fcf11 --- /dev/null +++ b/src/logic/core/player/animate_player.rs @@ -0,0 +1,49 @@ +use std::time::Duration; + +use bevy::prelude::*; +use bevy_rapier3d::dynamics::Velocity; + +use crate::{setup::{animations::AllAnimations, assets::GltfAssets}, comps::core::markers::{player::Player, proxy::character::player_character::PlayerCharacter}, ui::game::game_ui_state::GameUiState}; + +use super::player_movement::{PlayerLinearYState, PlayerLinearXZState}; + +#[allow(unused)] +pub fn animate_player( + all_animations: Res, + assets_gltf: Res, + player_query: Query< + ( + &Velocity, + &PlayerLinearYState, + &PlayerLinearXZState, + ), + ( + With, + Changed, + Changed + ) + >, + mut player_character_animation_player_query: Query<&mut AnimationPlayer, With>, + time: Res