mbrea-c / bevy_animation_graph

Animation graphs in Bevy!
Apache License 2.0
102 stars 5 forks source link

Handling of looping animations #27

Open mbrea-c opened 9 months ago

mbrea-c commented 9 months ago

How should this library handle looping animations?

Current state

At the moment there exists a Loop node that causes the input animation to loop indefinitely. However, this necessarily forces the duration data returned by a node's duration query to support representing an infinite duration, which forces special case handling in other parts of the codebase.

Possible alternatives

Looping is handled by animation player

Only allow finite durations. We could replace the Loop node with a LoopNTimes node that repeats an animation a fixed number of times. The looping would then be handled further up the chain, in the animation player component. The configuration for whether to loop could be kept either in the animation player or in the graph itself, with the animated scene option granting more flexibility.

Looping is handled in animation clip node

Another option is to configure whether to loop in the animation clip node itself. This seems to be what Bobby Angelov's engine does (see here).