-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - animation player #4375
Conversation
Co-authored-by: Jakob Hellermann <[email protected]>
Regarding the keyframes, I thought of remembering the Choosing an arbitrary position on the track would still require some kind of traversal, I think. |
That's generally a good idea in my opinion 👍 To elaborate a bit more: From my experience, when working with animations finding the keyframe works very well with these two strategies:
* The cached value of This assumes that the framerate of the keyframes isn't significantly higher than the playback speed. |
A keyframe cursor is generally useful for linear playback which this player is mostly intended for. For a more realistic modern use case where we have multiple blended clips in any given state, random seeks become more common (think transitioned blending and arbitrary gameplay driven blend states), which is actually negatively impacted when using a cursor. For this PR, I think it's fine to use as is but we may want to revisit if it's worth the complexity as we scale this. |
Awesome! Love the new user-facing api. |
Switched they keyframe lookup to a binary search. |
I'm down to optimize for implementation simplicity, given the timelines we're dealing with here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is in a good spot for 0.7 and provides a reasonable starting point for future improvements. Well done!
I'll hold off on other approvals for a day or so, then I'll merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handle playing animations in reverse?
now it does 👍 |
) { | ||
if !*done { | ||
if let Ok(mut player) = player.get_single_mut() { | ||
player.play_animation(animations.0[0].clone_weak()).repeat(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... Looking from a use perspective AnimationPlayer would look prettier if it was just Animation.
system param
animations: Query<&mut Animation>,
then later
if let Ok(mut animation) = animations.get_single_mut() {
animation.play(fox_animations.0[0].clone_weak()).repeat();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like the bias toward "nicer names", but in this particular case, I think AnimationPlayer is the better name. It represents a thing that plays animation, not a thing that is Animation. I'm more open to renaming AnimationClip to Animation, but I'm also happy with the current name, for now.
Additionally, we have plans for a more general "bevy animation system". It probably makes sense to reserve the Animation name until we sort out how that fits in to this.
bors r+ |
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
Objective
Transform
sSolution
animated_fox.mp4