This plugin is currently not very convenient to use: the target scene needs to be added, a system must then find the bevy::animation::AnimationPlayer in the instantiated scene, replace it with an AnimationGraphPlayer and finally add the desired animation graph to it.
This would be better handled by having an asset specifying the scene to be loaded together with the path (using entity Names) of the AnimationPlayer to be replaced and the asset path of the animation graph that should be played.
Solution
Provide AnimatedScene assets and an appropriate asset loader. Animated scenes are defined in .animscn.ron asset files as follows:
Once the animated scene is finished successfully spawning, an AnimatedSceneInstance component will be added to it. For convenience, this component contains the entity id of the child containing the AnimationGraphPlayer, in case the user decides to manually set some animation graph parameters. If the animated scene spawning fails, (e.g. because the given path_to_player is incorrect), an error will be printed and the AnimatedSceneFailed component will be added instead.
Objective
This plugin is currently not very convenient to use: the target scene needs to be added, a system must then find the
bevy::animation::AnimationPlayer
in the instantiated scene, replace it with anAnimationGraphPlayer
and finally add the desired animation graph to it.This would be better handled by having an asset specifying the scene to be loaded together with the path (using entity
Name
s) of theAnimationPlayer
to be replaced and the asset path of the animation graph that should be played.Solution
Provide
AnimatedScene
assets and an appropriate asset loader. Animated scenes are defined in.animscn.ron
asset files as follows:where
source
is the asset path of the original scenepath_to_player
is the path (vector of entityName
s) to the originalAnimationPlayer
.animation_graph
is the asset path of theAnimationGraph
we want to playback.We can now simply instantiate an
AnimatedSceneBundle
with the givenAnimatedScene
handle, just like we would do with a regular scene:Once the animated scene is finished successfully spawning, an
AnimatedSceneInstance
component will be added to it. For convenience, this component contains the entity id of the child containing theAnimationGraphPlayer
, in case the user decides to manually set some animation graph parameters. If the animated scene spawning fails, (e.g. because the givenpath_to_player
is incorrect), an error will be printed and theAnimatedSceneFailed
component will be added instead.