Open
Description
How can Bevy's documentation be improved?
bevy_animation::AnimationPlayer
doesn't explain:
- how you should create an animation player
- if you even should create an animation player manually
- how this interacts with
AnimationTransitions
and glTF scenes
When I was trying to spawn an entity with animations, I was following the animated fox example, but tried to simplify it. My code looked approximately like:
let mut anim_player = AnimationPlayer::default();
let mut transitions = AnimationTransitions::new();
transitions
.play(&mut anim_player, idle_animation, Duration::ZERO)
.repeat();
commands
.spawn((
SceneBundle {
scene: my_entity_gltf_scene.clone(),
..default()
},
anim_player,
transitions,
my_anim_graph.clone(),
));
However, this is wrong because here I'm creating my own AnimationPlayer
, when I should actually be using the player created by the scene when it's instantiated. What I actually have to do is spawn the SceneBundle in one system, wait for the scene to be instantiated, and use a second system to use the automatically-created AnimationPlayer
(I assume because the scene automatically populates it with some important data?). It's not really documented that this is specifically how you're meant to do this.
Activity