Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(0.12 regression) Can't play animation in more than one scene #10512

Closed
ostwilkens opened this issue Nov 11, 2023 · 4 comments
Closed

(0.12 regression) Can't play animation in more than one scene #10512

ostwilkens opened this issue Nov 11, 2023 · 4 comments
Labels
A-Animation Make things move and change over time A-Scenes Serialized ECS data stored on the disk P-Regression Functionality that used to work but no longer does. Add a test for this! S-User-Error This issue was caused by a mistake in the user's approach
Milestone

Comments

@ostwilkens
Copy link
Contributor

Bevy version

0.12

[Optional] Relevant system information

2023-11-11T21:29:02.719346Z  INFO bevy_winit::system: Creating new window "App" (0v0)
2023-11-11T21:29:03.010640Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2070", vendor: 4318, device: 7938, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "536.67", backend: Vulkan }
2023-11-11T21:29:03.653577Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 10 Education", kernel: "19045", cpu: "Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz", core_count: "6", memory: "31.9 GiB" }

What you did

Refer to the same Handle<AnimationClip> on two AnimationPlayers

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, setup_scene_once_loaded)
        .run();
}

#[derive(Resource)]
struct Animation(Handle<AnimationClip>);

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.insert_resource(Animation(asset_server.load("foxes.glb#Animation0")));
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(0.0, 0.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..default()
    });
    commands.spawn(SceneBundle {
        scene: asset_server.load("foxes.glb#Scene0"),
        ..default()
    });
    commands.spawn(SceneBundle {
        scene: asset_server.load("foxes.glb#Scene1"),
        ..default()
    });
}

fn setup_scene_once_loaded(
    animation: Res<Animation>,
    mut players: Query<&mut AnimationPlayer, Added<AnimationPlayer>>,
) {
    for mut player in &mut players {
        player.play(animation.0.clone()).repeat();
    }
}

foxes.glb
minimal reproduction project.zip

What went wrong

  • what were you expecting?
    I was expecting both scenes to animate
  • what actually happened?
    Only the first animates, and the log is filled with
    WARN bevy_animation: Animation player on 58v0 did not match any entity paths.

Additional information

The issue appeared after migrating from 0.11 to 0.12

@ostwilkens ostwilkens added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 11, 2023
@alice-i-cecile alice-i-cecile added A-Animation Make things move and change over time and removed S-Needs-Triage This issue needs to be labelled labels Nov 11, 2023
@alice-i-cecile alice-i-cecile added this to the 0.12.1 milestone Nov 11, 2023
@alice-i-cecile alice-i-cecile added the A-Scenes Serialized ECS data stored on the disk label Nov 11, 2023
@idanarye
Copy link

Aren't Scene0 and Scene1 different scenes? Are you sure Animation0 fits them both?

What happens when you try to play it only on Scene1?

@ostwilkens
Copy link
Contributor Author

Aren't Scene0 and Scene1 different scenes? Are you sure Animation0 fits them both?

Yes, Scene1 is a clone of Scene0.

What happens when you try to play it only on Scene1?

I can't believe I didn't try this! It fails as well. That's even more weird, seeing as the scenes are identical.
This means the title isn't accurate, but I have no theories about what's happening. I will have to do more testing.

For context, my game uses a single .glb containing multiple rigged scenes, which use the same animations (as they are all humanoids).

image

@nicopap
Copy link
Contributor

nicopap commented Nov 13, 2023

FYI you can edit the title by using the "edit" button right next to the title.

This might be caused by the root entity name's not matching. This was removed, as it was considered a bug.

Consider using identical names for your scenes. If it's not possible in your 3D editor (for example, in blender), consider using https://github.com/nicopap/bevy-scene-hook to swap the name when the scene is spawned.

@nicopap nicopap added P-Regression Functionality that used to work but no longer does. Add a test for this! and removed C-Bug An unexpected or incorrect behavior labels Nov 13, 2023
@ostwilkens
Copy link
Contributor Author

@nicopap Thank you for checking in on this issue!

I was confused as to how an entity name is relevant, as my animations (Actions) in blender AFAIK aren't connected to a specific scene. I just store them in the file.

image

However, you prompted me to look into the structure of the exported GLTF file. And apparently, all animations are re-exported for each scene!

image

So I guess this issue was born out of my lack of GLTF understanding, combined with a bevy bug, which I saw as a feature 😀

I will load each separate animation for the corresponding character, and it should work. Closing.

@alice-i-cecile alice-i-cecile added the S-User-Error This issue was caused by a mistake in the user's approach label Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Animation Make things move and change over time A-Scenes Serialized ECS data stored on the disk P-Regression Functionality that used to work but no longer does. Add a test for this! S-User-Error This issue was caused by a mistake in the user's approach
Projects
None yet
Development

No branches or pull requests

4 participants