Fix broken root motion scale & Refactor API & Add sample codes in documentation #69199
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.
Fixes #58061
The current root motion scale is completely broken due to incorrect initial values and application process. This PR fix the initial value and the application process, and make the returned root motion scale to be able to used by the accumulator1.
Before with
transform.basis *= root_motion_transform.basis
:root1.mp4
After with accumulator:
root2.mp4
rootmotiondemo.zip
Match motion in RootMotionView and AnimationPlayer
The apply order of the root motion position and root motion rotation differs between AnimationPlayer and RootMotionView. Considering the order in which Bone Pose is applied, the root motion position shuold not affected by the root motion rotation, so the current motion in RootMotionView is incorrect, fixed.
Add sample code to document for apply root motion
In above case, the root motion rotation must respect the object's orientation at the start of the animation. So I added the sample code in the documentation. Also, the scale needs to respect the object's value and accumulator at the start of the animation as well. I added it in the documentation too.
Change API
get_root_motion_transform()
toget_root_motion_position/rotation/scale()
For these reasons, it makes more sense to separate them as TRS than to take the root motion out as Transform3D.
Footnotes
For example, if you animate 4 times and want the Scale to transition like
1
->3
->5
->7
, you do not need to use the accumulator, but If you want to do Scale transitions like1
->3
->9
->27
, you need accumulator. ↩