-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Root motion implementation #24201
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
Open
Hilpogar
wants to merge
37
commits into
bevyengine:main
Choose a base branch
from
Hilpogar:root-motion-part-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Root motion implementation #24201
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
f478556
change animation behavior for root bone
Hilpogar e23ec28
add a test for root motion
Hilpogar ff1e5dd
handle animation loops
Hilpogar bdb0238
check backward direction
Hilpogar a465895
add the RootMotion component
Hilpogar 02bb39d
add rotation to tests
Hilpogar fe51b68
refactor tests
Hilpogar 7b1c85c
tests work with blending
Hilpogar 08f5d85
create fetch_curve_evaluator method
Hilpogar 22171af
documentation
Hilpogar 811ff37
don't extract rotation if not configured
Hilpogar 2010ea2
change test values to have bigger potential errors
Hilpogar 502f317
add a system to remove RootMotion when it's disabled
Hilpogar b977aa1
add root motion example
Hilpogar 7fcad9c
add release note
Hilpogar 23b2fe6
missed formatting
Hilpogar 74a855a
clippy
Hilpogar 8b7f259
ci errors
Hilpogar bb3fd87
fix description causing issues
Hilpogar 7ff8e63
add PartialEq to RootMotionMode
Hilpogar 0f122e2
Update examples/animation/root_motion.rs
Hilpogar 5cd174e
Update crates/bevy_animation/src/lib.rs
Hilpogar a1e95e7
fix suggestion
Hilpogar 9931310
clean RootMotion when AnimationPlayer is removed
Hilpogar 65cbf7d
test if RootMotion is removed with AnimationPlayer
Hilpogar cb434d9
check if disabling root_motion_target removes RootMotion the next frame
Hilpogar 7c289a9
apply root motion after animation systems
Hilpogar c6074c8
add track_caller to test helper functions
Hilpogar 24ab2cc
add Clone and PartialEq to RootMotion
Hilpogar 0430376
move find_root_bone_recursive in bevy_animation
Hilpogar dc9eded
move root motion config from AnimationPlayer to RootMotionConfig
Hilpogar b6e8ed5
document RootMotionMode match
Hilpogar 70437d0
document FoxRootMotion.glb
Hilpogar a4163d5
add a migration guide for AnimationCurveEvaluator
Hilpogar 2d79ad2
fix ci import issue
Hilpogar 6775369
change animated_field! to remove the need to import AnimatedField
Hilpogar 9c7b15b
Merge branch 'main' into root-motion-part-3
Hilpogar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
_release-content/migration-guides/animation_curve_evaluator_commit.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| title: Change function signature of commit in AnimationCurveEvaluator | ||
| pull_requests: [24201] | ||
| --- | ||
|
|
||
| The root motion feature needs to access the animated entity after the curves are applied. For this reason, the commit method of | ||
| AnimationCurveEvaluator changed from : | ||
|
|
||
| ```rust | ||
| fn commit(&mut self, entity: AnimationEntityMut) -> Result<(), AnimationEvaluationError>; | ||
| ``` | ||
|
|
||
| to | ||
|
|
||
| ```rust | ||
| fn commit(&mut self, entity: &mut AnimationEntityMut) -> Result<(), AnimationEvaluationError>; | ||
| ``` | ||
|
|
||
| Passing the AnimationEntityMut by mutable reference is now necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| title: Root Motion | ||
| authors: ["@Hilpogar", "@emberlightstudios"] | ||
| pull_requests: [24201] | ||
| --- | ||
|
|
||
| In animation and game development, root motion is a technique where the movement of a character is driven directly by the animation’s root bone instead of being controlled purely by code or physics. | ||
| It is used to create more natural, accurate movements such as walking, climbing, or attacks, by synchronizing the character’s in-game position with the animation itself. | ||
|
|
||
| You can now use this technique by using the `set_root_motion_target` method in the `AnimationPlayer`. To do so, you need to get the `AnimationTargetId` of your model's root motion bone. | ||
| It can be the root bone or any bone you want. When a bone is configured to be used for root motion, its position and / or rotation will be erased each frame and the delta with the previous | ||
| frame is stored in the `RootMotion` component inside the `AnimationPlayer`'s entity. You can configure if the root motion should extract translation and rotation or just translation with the `set_root_motion_mode` method in `AnimationPlayer`. |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # What's FoxRootMotion.glb | ||
|
|
||
| This model is the same as Fox.glb but with an additional curve for translation in the `b_Root_00` bone of the `run` animation. | ||
| It's used to illustrate the root motion in the root_motion example. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note for someone to check if this asset is allowed to be committed or if it needs to be a remote/web asset.
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.
Is this because of potential copyright or licensing issues with the model, or is it just to avoid overloading the repository? If it’s a licensing issue, please note that this is simply the existing fox model to which I’ve added root motion to the running animation.
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.
It’s to do with repo size / bloat. E.g., see #23567 (comment)
I don’t know the bytes threshold but AFAIK, I think bevy wants to avoid putting more assets in this repo if possible.
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.
We need a comment indicating what the changes to the file are here. Notably in case it ever needs to be modified or understood in the future. Otherwise it will be hard for future contributors to comprehend why this is a separate file.
Personally I think a
FoxRootMotion.mdthat explains the steps taken to create the new file from the original would work.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 agree with that. This is not so big that I think we have to move it out though IMO, but clear guidance here would have been nice.
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've created a ForRootMotion.md containing the instructions to recreate the file. This is a very slight modification of the file, do you think the instructions are clear enough?