Skip to content

More erganomic AnimationPlayer API #5848

@asafigan

Description

@asafigan

What problem does this solve or what need does it fill?

Right now there are very few methods on AnimationPlayer which makes it more difficult to use than it needs to be.

I commonly need to be able to know:

  • the current animation
  • if it the current animation is finished
  • if there is no current animation (I think this is the case right now it the current animation clip is the default handle)

What solution would you like?

Adding some basic methods like animation_clip() and is_finished().

Also a way of figuring out if there is actually an animation. This could be either a method or return an Option from animation_clip() or just documenting that animation_clip() could return the default handle and that means that there is no animation playing.

Also maybe the default AnimationPlayer (like the one added to an entity in a gltf scene) should have better defaults like being paused and/or finished.

What alternative(s) have you considered?

You can manually track the current animation clip using a separate component but it is really annoying because you have to query and update an extra component.

You can calculate if the animation is finished if you know the current AnimationClip and look it up in Assets<AnimationClip> to find the length and comparing that to the AnimationPlayer's elapsed time. Again super annoying and probably requires to tack the current animation.

Additional context

These are issues that I came across in developing my Bevy Jam 2 submission. You can see how I worked around this in the code.

I am willing to do the implementation on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AnimationMake things move and change over timeC-FeatureA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions