Closed itstheceo closed 5 months ago
Thanks for reaching out.
Maybe bevy_asset_loader has some way to load it into a hashmap, that I am not sure about.
What you can do is just load the whole AnimationClip2DSet, which is a Hashmap of Handle
#[derive(AssetCollection, Resource)]
pub struct GameAssets {
#[asset(path = "player/anim.trickfilm")]
pub player_animations_idle: Handle<AnimationClip2DSet>,
...
}
fn system(
animation_clip_sets: Res<Assets<AnimationClip2DSet>>,
...
) {
let animation_clip_set = animation_clip_sets.get(assets.player_animations_idle).unwrap(); /* For brevity */
let animation = match player.state {
PlayerState::Idling => {
if player.direction.y < 0.0 {
animation_clip_set.get("idle_down")
} else if player.direction.y > 0.0 {
animation_clip_set.get("idle_up")
} else if player.direction.x < 0.0 {
animation_clip_set.get("idle_left")
} else {
animation_clip_set.get("idle_right")
}
},
...
}
...
}
Ah I see, that's nifty. Thanks for the prompt response!
Hello! I've just started using the plugin, and it works great (with bevy_asset_loader too)!
I have a question around accessing the animation clips on the AssetCollection, if you could kindly consider the following:
And then loading via an AssetCollection
Currently I access them by index in the
Vec
as follows (which feels a bit ugly though maybe related to my inexperience with Bevy?):However it would be awesome if I could retrieve them by their names, i.e
#idle_right
and such! Let me know what you think.Cheers.