From c186019b52784fb1f9bb0f7940df7de58e0b9070 Mon Sep 17 00:00:00 2001 From: Franklin Blanco Date: Sun, 17 Sep 2023 17:15:31 -0700 Subject: [PATCH] WORKS!! FINALLY ANIMATION ON REPEAT --- assets/weapons/m4a1_rifle.glb | Bin 55106408 -> 55110836 bytes src/logic/core/animations/mod.rs | 13 ------------- src/logic/core/guns/spawn_firearm.rs | 6 +++--- src/logic/core/mod.rs | 3 +-- src/logic/core/player/camera_effects.rs | 12 ++++++++++++ src/scenes/scene1/init.rs | 4 ++-- src/setup/animations.rs | 4 ++-- 7 files changed, 20 insertions(+), 22 deletions(-) delete mode 100644 src/logic/core/animations/mod.rs diff --git a/assets/weapons/m4a1_rifle.glb b/assets/weapons/m4a1_rifle.glb index 539abd980a017acd4ace605bf446a2b2da496e7b..366b2adf0485d2ea8da2acf6bf4cce5536bb6dd0 100644 GIT binary patch delta 11165 zcmdtocX$-l!Uk}X5E5#7LP^~eAlYoDmrz2lB1lz~5+Fb%Bp8B1_Bo3g4XmTsx4s#~Vv#%7YF zXsRU3s-!BKAt|zAVoOQVB}vvS!_+iWl?_Ah=XQ!DJjk^99`gZp{ix7wkBIRnx@;D>6SgJsoRo? z%d#Z}`|*NgSu(w{hRZSy+cp)e-+0u<;NkfNLyGfQWCh2rsFPMjg?R(6UNNdiHgrRg zRYR9FMK&cpFH^GIhDWn3%aBc6wyZ0L<*Y^ZXsU&aGA-4#6)n})Svj~;Q)Vjl^4J>&~NmJ2kwv8)PC6n#Tli8}Qo3vejesL*^RvN>fu*T#aI*`pqlaR=cciFRzVE(>bcGqZgaHZphs=rvcHE(7oAr z6kU-l%T}?PO{lSB=~!W?Xi2mZ)>)>k8|ZWv|E5X4RZ`Kcsi<9B$890&7P_aV=x9@% z4|Sxgmcn+Boi;_0Ez`t*=)9J$X`(bVdd|=hQS4&4dujk{5i%CA%PD3&S7657+$ zaJyXSeprj+tGEks6XNgArK1BGXkNueg(|+6i5{S!q0y7jZ4Fb`B$WlbuyWYd)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)ph -} - -/// This represents a blender keyframe. -/// In the system part every keyframe's transform will be lerped linearly with the time in between them. -pub struct AnimationKeyFrame { - pub transform: Option, - pub visibility: Option, - pub time: f32, -} \ No newline at end of file diff --git a/src/logic/core/guns/spawn_firearm.rs b/src/logic/core/guns/spawn_firearm.rs index 9be1f48..4307994 100644 --- a/src/logic/core/guns/spawn_firearm.rs +++ b/src/logic/core/guns/spawn_firearm.rs @@ -5,7 +5,7 @@ use bevy::prelude::*; use crate::{ comps::core::markers::{holdable::InPlayerHands, player::PlayerHand, firearm::MagazineData}, constants::player_values::DEFAULT_PLAYER_FIREARM, - utils, + utils, setup::animations::FirearmAnimations, }; use super::player_firing::PlayerFiringInfo; @@ -45,7 +45,7 @@ pub fn spawn_firearm_on_player_hands( TimerMode::Once, ); // Load animations - /*commands.insert_resource(FirearmAnimations { reload_magazine: asset_server.load(format!("{}#Animation0", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path)), - rock_charging_handle: asset_server.load(format!("{}#Animation1", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path)) })*/ + commands.insert_resource(FirearmAnimations { reload_magazine: asset_server.load(format!("{}#Animation0", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path)), + rock_charging_handle: asset_server.load(format!("{}#Animation1", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path)) }) } } diff --git a/src/logic/core/mod.rs b/src/logic/core/mod.rs index a33b729..bedc585 100644 --- a/src/logic/core/mod.rs +++ b/src/logic/core/mod.rs @@ -1,3 +1,2 @@ pub mod guns; -pub mod player; -pub mod animations; \ No newline at end of file +pub mod player; \ No newline at end of file diff --git a/src/logic/core/player/camera_effects.rs b/src/logic/core/player/camera_effects.rs index e69de29..3e77089 100644 --- a/src/logic/core/player/camera_effects.rs +++ b/src/logic/core/player/camera_effects.rs @@ -0,0 +1,12 @@ +use bevy::prelude::*; + +use crate::setup::animations::FirearmAnimations; + +pub fn setup_scene_once_loaded( + animations: Res, + mut players: Query<&mut AnimationPlayer, Added>, +) { + for mut player in &mut players { + player.play(animations.reload_magazine.clone_weak()).repeat(); + } +} \ No newline at end of file diff --git a/src/scenes/scene1/init.rs b/src/scenes/scene1/init.rs index a9764e0..b118bc2 100644 --- a/src/scenes/scene1/init.rs +++ b/src/scenes/scene1/init.rs @@ -10,7 +10,7 @@ use crate::{ }, hands::capture_hand_usage, player_vertical_sync::sync_player_y_state, - spawn_player::spawn_player, + spawn_player::spawn_player, camera_effects::setup_scene_once_loaded, }, }, }; @@ -43,6 +43,6 @@ pub fn load_scene(application: &mut App) { application.add_systems(Update, capture_hand_usage); application.add_systems(Startup, setup_lighting); - //application.add_systems(Update, setup_scene_once_loaded); + application.add_systems(Update, setup_scene_once_loaded); //application.add_systems(Update, play_animation); } diff --git a/src/setup/animations.rs b/src/setup/animations.rs index 2cd2990..dfea75d 100644 --- a/src/setup/animations.rs +++ b/src/setup/animations.rs @@ -1,7 +1,7 @@ -/*use bevy::prelude::*; +use bevy::prelude::*; #[derive(Resource)] pub struct FirearmAnimations { pub reload_magazine: Handle, pub rock_charging_handle: Handle, -}*/ \ No newline at end of file +} \ No newline at end of file