`AnimationPlayer` doesn't explain how it is created
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## How can Bevy's documentation be improved?
[`bevy_animation::AnimationPlayer`](https://docs.rs/bevy_animation/latest/bevy_animation/struct.AnimationPlayer.html) 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:
```rust
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.
Contributor guide
Assessment
This issue has not been assessed yet.