Banging my head against this animation bug...

bevy0.12
Elijah C. Voigt 2 years ago
parent 1219079c95
commit a26102576b

@ -170,16 +170,18 @@ fn hydrate_camera(
assets_map: Res<AssetsMap>, assets_map: Res<AssetsMap>,
gltfs: Res<Assets<Gltf>>, gltfs: Res<Assets<Gltf>>,
state: Res<State<game::TurnState>>, state: Res<State<game::TurnState>>,
_clips: Res<Assets<AnimationClip>>,
mut players: Query<&mut AnimationPlayer>, mut players: Query<&mut AnimationPlayer>,
mut commands: Commands, mut commands: Commands,
) { ) {
events events
.iter() .iter()
.filter(|(name, _)| name.as_str() == "GameCam") .find(|(name, _)| name.as_str() == "GameCam")
.for_each(|(_, entity)| { .iter()
.for_each(|(_name, entity)| {
info!("Initialize 3d camera"); info!("Initialize 3d camera");
// Populate the components for the camera // Populate the components for the camera
commands.entity(entity).insert(( commands.entity(*entity).insert((
Display3d, Display3d,
DisplayState::Display3d, DisplayState::Display3d,
Camera3dBundle { Camera3dBundle {
@ -208,15 +210,19 @@ fn hydrate_camera(
let gltf = gltfs.get(&assets_map.models).expect("Load GLTF content"); let gltf = gltfs.get(&assets_map.models).expect("Load GLTF content");
// Set it to the default position by starting the initial animation // Set it to the default position by starting the initial animation
if let Ok(mut player) = players.get_mut(entity) { if let Ok(mut player) = players.get_mut(*entity) {
debug!("Animations: {:?}", gltf.named_animations.keys()); debug!("Animations: {:?}", gltf.named_animations.keys());
// GameCamIntro1, GameCamIntro2, GameCamSide1>2, GameCamSide2>1 // GameCamIntro1, GameCamIntro2, GameCamSide1>2, GameCamSide2>1
info!("Animation 1: {:?}", _clips.get(gltf.named_animations.get("GameCamIntro1").unwrap()));
info!("Animation 2: {:?}", _clips.get(gltf.named_animations.get("GameCamIntro2").unwrap()));
let animation = match state.get() { let animation = match state.get() {
game::TurnState::SideA => gltf.named_animations.get("GameCamIntro1"), game::TurnState::SideA => gltf.named_animations.get("GameCamIntro1"),
game::TurnState::SideB => gltf.named_animations.get("GameCamIntro2"), game::TurnState::SideB => gltf.named_animations.get("GameCamIntro2"),
}; }.expect("Camera startup");
info!("Compatible: {:?}", _clips.get(animation).unwrap().compatible_with(_name));
info!("Entity: {:?}", *entity);
player player
.play(animation.expect("Camera Startup").clone()) .play(animation.clone())
.pause(); .pause();
} }
}); });

Loading…
Cancel
Save