I implement root motion in my action game in this way
https://github.com/YuzikiRain/Learn/blob/master/Unity/Spine/implement%20root%20motion%20in%20special%20way.md
(environment: Unity2018.4.1f, Spine runtime for unity 3.7)
just copy the root bone motion baked and paste to gameObject position, but it's a little complex, and I wonder is there any plan to implement root motion in Unity runtime?
YukiRain
2.5 years ago
- YukiRain
- Posts: 3
ara
There was a experimental version of rm:
https://github.com/pharan/spine-unity-experimental/tree/spine-rootmotion
I'm not sure when it will become release version.
Also wondering.
https://github.com/pharan/spine-unity-experimental/tree/spine-rootmotion
I'm not sure when it will become release version.
Also wondering.
2.5 years ago
-
ara - Posts: 59
YukiRain
It takes me more than 3days to find a solution for root motion, also I find this solution @ara, but unfortunately it does not work for SkeletonMecanim, it just work for SkeletonAnimation, and I finish most of work in Mecanim in my action game, so Arts can naturally complete animation with root motion in Spine Editor, I just need to add them to Unity Animator, set some parameters to translate between state.
2.5 years ago
- YukiRain
- Posts: 3
Harald
Thanks for sharing this detailled writeup YukiRain.
Since this is an important feature, we will add it to the runtime in the future, there is now a combined ticket here:
https://github.com/EsotericSoftware/spine-runtimes/issues/1417
Since this is an important feature, we will add it to the runtime in the future, there is now a combined ticket here:
https://github.com/EsotericSoftware/spine-runtimes/issues/1417
2.5 years ago
-
Harald - Posts: 3931
YukiRain
glad to hear that! and hope my solution can help others who need root motion.
2.5 years ago
- YukiRain
- Posts: 3
Harald
We can gladly announce that root motion support has arrived for 
You can download the updated 3.8 spine-unity unitypackage here as usual:
Spine Unity Download
While the spine-unity documentation sections are currently being updated with the new feature, I'm sure you'll figure it out.
From the Changelog:
---
The documentation sections have just been added/updated:
spine-unity Runtime Documentation: Enabling Root Motion
spine-unity Runtime Documentation: SkeletonRootMotion
SkeletonAnimation
, SkeletonMecanim
and SkeletonGraphic
! 
You can download the updated 3.8 spine-unity unitypackage here as usual:
Spine Unity Download
While the spine-unity documentation sections are currently being updated with the new feature, I'm sure you'll figure it out.

From the Changelog:
Added Root Motion support forSkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
via new componentsSkeletonRootMotion
andSkeletonMecanimRootMotion
. TheSkeletonAnimation
andSkeletonGraphic
component Inspector now provides a lineRoot Motion
withAdd Component
andRemove Component
buttons to add/remove the newSkeletonRootMotion
component to your GameObject. TheSkeletonMecanim
Inspector detects whether root motion is enabled at theAnimator
component and adds aSkeletonMecanimRootMotion
component automatically.
---
The documentation sections have just been added/updated:
spine-unity Runtime Documentation: Enabling Root Motion
spine-unity Runtime Documentation: SkeletonRootMotion
1.5 years ago
-
Harald - Posts: 3931
ara
Harald wrote:We can gladly announce that root motion support has arrived forSkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
!
You can download the updated 3.8 spine-unity unitypackage here as usual:
Spine Unity Download
While the spine-unity documentation sections are currently being updated with the new feature, I'm sure you'll figure it out.![]()
From the Changelog:Added Root Motion support forSkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
via new componentsSkeletonRootMotion
andSkeletonMecanimRootMotion
. TheSkeletonAnimation
andSkeletonGraphic
component Inspector now provides a lineRoot Motion
withAdd Component
andRemove Component
buttons to add/remove the newSkeletonRootMotion
component to your GameObject. TheSkeletonMecanim
Inspector detects whether root motion is enabled at theAnimator
component and adds aSkeletonMecanimRootMotion
component automatically.
---
The documentation sections have just been added/updated:
spine-unity Runtime Documentation: Enabling Root Motion
spine-unity Runtime Documentation: SkeletonRootMotion

1.5 years ago
-
ara - Posts: 59
Harald
You're welcome, very glad it's finally done!
1.5 years ago
-
Harald - Posts: 3931
yinmo
Hi, HaraldHarald wrote:We can gladly announce that root motion support has arrived forSkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
!
You can download the updated 3.8 spine-unity unitypackage here as usual:
Spine Unity Download
While the spine-unity documentation sections are currently being updated with the new feature, I'm sure you'll figure it out.![]()
From the Changelog:Added Root Motion support forSkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
via new componentsSkeletonRootMotion
andSkeletonMecanimRootMotion
. TheSkeletonAnimation
andSkeletonGraphic
component Inspector now provides a lineRoot Motion
withAdd Component
andRemove Component
buttons to add/remove the newSkeletonRootMotion
component to your GameObject. TheSkeletonMecanim
Inspector detects whether root motion is enabled at theAnimator
component and adds aSkeletonMecanimRootMotion
component automatically.
---
The documentation sections have just been added/updated:
spine-unity Runtime Documentation: Enabling Root Motion
spine-unity Runtime Documentation: SkeletonRootMotion
Thanks for delivering such a wonderful feature
I wonder if it is possible to achieve "Delta Correction" as the Doom Talk demonstrated in this talk:
https://youtu.be/3lO1q8mQrrg?t=486
I want the distance of the root motion stretchable.
Basically I want the good bits from both moving objects with code(flexibility with physics) and Root Motion(the visual).
I tried to use SkeletonUtilityBone, but it seems not to work with neither override nor follow mode.
I tried to move the rigidbody2D, the problem is that "rigidBody2D.MovePosition" can only be triggered once in each frame, and the RootMotion code used it already.
Can you offer some advice to achieve this "Delta Correction", or better, can you integrate it into the official runtime.
1.5 years ago
- yinmo
- Posts: 20
Harald
Thanks for sharing this great idea, this would indeed be a very nice addition! We could easily provide
What would be more work is to:
1) Calculate the total distance automatically from the animations and use this value for the calculations.
2) Update in the middle of an animation when the goal of the animation changes, depending on the remaining root motion distance.
What do you think, would simple
Root Motion Scale X/Y
parameters which would allow for basic delta correction. You would then only need to update the scale when e.g. a leap animation has just started, provided that you know the total root motion distance for your animations.What would be more work is to:
1) Calculate the total distance automatically from the animations and use this value for the calculations.
2) Update in the middle of an animation when the goal of the animation changes, depending on the remaining root motion distance.
What do you think, would simple
Root Motion Scale X/Y
parameters be helpful for your use case? Please let me know in case I forgot to consider something important. 1.5 years ago
-
Harald - Posts: 3931
yinmo
Hi, againHarald wrote:Thanks for sharing this great idea, this would indeed be a very nice addition! We could easily provideRoot Motion Scale X/Y
parameters which would allow for basic delta correction. You would then only need to update the scale when e.g. a leap animation has just started, provided that you know the total root motion distance for your animations.
What would be more work is to:
1) Calculate the total distance automatically from the animations and use this value for the calculations.
2) Update in the middle of an animation when the goal of the animation changes, depending on the remaining root motion distance.
What do you think, would simpleRoot Motion Scale X/Y
parameters be helpful for your use case? Please let me know in case I forgot to consider something important.
What you proposed is superb.
What I originally aimed was to set a target position, then scale X/Y accordingly, which is enough to make the enemy animation look vivid and that's all I need.
Now you are saying you can make it scale X/Y constantly even if the target changes dring the animation, which opens the door for responsive and expressive player control.
But one thing worths noting is how and when you scale the X/Y parameters. Imagine an animation of a character crunches down for a few frames then Jumps for a few frames. If you allocate the extended distance evenly for every frame, the character would start to move at the crunching phase. If you scale the distance moved in each frame like the talk demonstrates, things would be good.
Thanks for allocating your time, I am really happy that you take it seriously. looking forward to your reply and update.
Good day.
BTW, is there any way to Calculate the total distance automatically from the animations in runtime? I'm making a game with an emphasis on animation priority, sometimes I don`t want the movement stretched, yet I need the movement data to help AI to make decisions. e.g Get the distance between the target and the AI object, then get all the movement distance from each available attack animation, pick out the ones that can reach the target, then randomly choose one.
1.5 years ago
- yinmo
- Posts: 20
Harald
Scaling root motion during the crunch-down part would just scale 0 root motion by a factor, still leaving it at 0. I never meant to add an evenly distibuted compensation offset, hence the nameyinmo wrote:But one thing worths noting is how and when you scale the X/Y parameters. Imagine an animation of a character crunches down for a few frames then Jumps for a few frames. If you allocate the extended distance evenly for every frame, the character would start to move at the crunching phase.
Root Motion Scale X/Y
.We will add some methods to retrieve the total root motion distance for an animation, I have created an issue ticket here:yinmo wrote:BTW, is there any way to Calculate the total distance automatically from the animations in runtime? I'm making a game with an emphasis on animation priority, sometimes I don`t want the movement stretched, yet I need the movement data to help AI to make decisions. e.g Get the distance between the target and the AI object, then get all the movement distance from each available attack animation, pick out the ones that can reach the target, then randomly choose one.
[unity] Root motion scale and delta compensation · #1754
Explaining it in the necessary detail would take just as long. We will let you know when the feature is implemented.
1.5 years ago
-
Harald - Posts: 3931
yinmo
Good to know, thanks a lotHarald wrote:Scaling root motion during the crunch-down part would just scale 0 root motion by a factor, still leaving it at 0. I never meant to add an evenly distibuted compensation offset, hence the nameyinmo wrote:But one thing worths noting is how and when you scale the X/Y parameters. Imagine an animation of a character crunches down for a few frames then Jumps for a few frames. If you allocate the extended distance evenly for every frame, the character would start to move at the crunching phase.Root Motion Scale X/Y
.We will add some methods to retrieve the total root motion distance for an animation, I have created an issue ticket here:yinmo wrote:BTW, is there any way to Calculate the total distance automatically from the animations in runtime? I'm making a game with an emphasis on animation priority, sometimes I don`t want the movement stretched, yet I need the movement data to help AI to make decisions. e.g Get the distance between the target and the AI object, then get all the movement distance from each available attack animation, pick out the ones that can reach the target, then randomly choose one.
[unity] Root motion scale and delta compensation · #1754
Explaining it in the necessary detail would take just as long. We will let you know when the feature is implemented.
1.5 years ago
- yinmo
- Posts: 20
Harald
The additional methods and parameters have been added.
From the changelog:
Spine Unity Download
We hope you like it!
Please let us know whether the additions satisfy your requirements for your use cases.
Here is an additional inofficial example Component that shows how
From the changelog:
New 3.8 unitypackages can now be downloaded here as usual:AddedRoot Motion Scale X/Y
parameters toSkeletonRootMotionBase
subclasses (SkeletonRootMotion
andSkeletonMecanimRootMotion
). Also providingAdjustRootMotionToDistance()
and other methods to allow for easy delta compensation. Delta compensation can be used to e.g. stretch a jump to a given distance. Root motion can be adjusted at the start of an animation or every frame viaskeletonRootMotion.AdjustRootMotionToDistance(targetPosition - transform.position, trackIndex);
.
Spine Unity Download
We hope you like it!

Here is an additional inofficial example Component that shows how
AdjustRootMotionToDistance()
can be used to compensate root motion to the position of a Transform.You do not have the required permissions to view the files attached to this post.
1.5 years ago
-
Harald - Posts: 3931
yinmo
Wow, that`s way faster than I thought, impressive speed.Harald wrote:The additional methods and parameters have been added.
From the changelog:New 3.8 unitypackages can now be downloaded here as usual:AddedRoot Motion Scale X/Y
parameters toSkeletonRootMotionBase
subclasses (SkeletonRootMotion
andSkeletonMecanimRootMotion
). Also providingAdjustRootMotionToDistance()
and other methods to allow for easy delta compensation. Delta compensation can be used to e.g. stretch a jump to a given distance. Root motion can be adjusted at the start of an animation or every frame viaskeletonRootMotion.AdjustRootMotionToDistance(targetPosition - transform.position, trackIndex);
.
Spine Unity Download
We hope you like it!Please let us know whether the additions satisfy your requirements for your use cases.
Here is an additional inofficial example Component that shows howAdjustRootMotionToDistance()
can be used to compensate root motion to the position of a Transform.
And yeah, the delta correction works perfectly as I desired.
Thank you very much.
But in regards to the method GetRemainingRootMotion(), it requires an animation applied to calculate the distance.
Is there a way to calculate the translation with a clip name? I need that info before animations are applied for some AI decisions.
1.5 years ago
- yinmo
- Posts: 20
Harald
You're welcome, glad it works as desired!
Regarding the clip name: please query it from
Regarding the clip name: please query it from
SkeletonData
:Animation animation = skeletonData.FindAnimation(animationName);
1.5 years ago
-
Harald - Posts: 3931
yinmo
Thanks a lotHarald wrote:You're welcome, glad it works as desired!
Regarding the clip name: please query it fromSkeletonData
:Animation animation = skeletonData.FindAnimation(animationName);
1.5 years ago
- yinmo
- Posts: 20
RemDust
Hello Root Motion lovers
I've been using the old experimental script for a while, with uneven results.
I consider upgrading for the new solution.
I have a few questions though :
1/ Do you guys have a nice and solid solution to enable/disable root motion exactly when needed ?
Right now I have marginal cases where my enemy jumps back n fourth during a single frame when switching from not Rooted to Rooted animations. I've been trying to use Start and Complete callbacks without really get rid off the problem completely.
2/ Delta compensation looks like a very nice feature but an actual exemple would be very helpful for beginners ^^
3/ Finally, if you guys already answered these questions or published guidelines or a tutorial on how to use this new component, please, shoot !
Thanks !!

I've been using the old experimental script for a while, with uneven results.
I consider upgrading for the new solution.

I have a few questions though :
1/ Do you guys have a nice and solid solution to enable/disable root motion exactly when needed ?
Right now I have marginal cases where my enemy jumps back n fourth during a single frame when switching from not Rooted to Rooted animations. I've been trying to use Start and Complete callbacks without really get rid off the problem completely.
2/ Delta compensation looks like a very nice feature but an actual exemple would be very helpful for beginners ^^
3/ Finally, if you guys already answered these questions or published guidelines or a tutorial on how to use this new component, please, shoot !

Thanks !!
1 year ago
- RemDust
- Posts: 223
Harald
I'm afraid this is a theoretical problem of switching between root motion and non-root motion animations. When switching to the non-root motion mode, the animation will immediately override the current position with an undesired one if the animation is not at the origin (0,0) position. As you said you tried using theRemDust wrote:
1/ Do you guys have a nice and solid solution to enable/disable root motion exactly when needed ?
Right now I have marginal cases where my enemy jumps back n fourth during a single frame when switching from not Rooted to Rooted animations. I've been trying to use Start and Complete callbacks without really get rid off the problem completely.
Start
and Complete
callbacks: do your animations start at position (0,0)?Good point. I have created an issue ticket here:RemDust wrote:2/ Delta compensation looks like a very nice feature but an actual exemple would be very helpful for beginners ^^
https://github.com/EsotericSoftware/spine-runtimes/issues/1873
For now I can only offer a simple
RootMotionDeltaCompensation
example component, an example scene will take a bit longer to make (mostly because a skeleton asset requires added root motion animations and release for both 3.8 and 4.0-beta). The example component has been added on the 3.8 branch (4.0-beta will follow soon), a new 3.8 unitypackage is available for download here as usual:Spine Unity Download
Please let us know if this component helps, or just ask straight ahead if you have any questions. Unfortunately changes for the 4.0-beta release are keeping us a bit too busy for creating the example scene and skeleton for now.
1 year ago
-
Harald - Posts: 3931
RemDust
Hi Harald,Harald wrote:As you said you tried using the Start and Complete callbacks: do your animations start at position (0,0)?
Yes, all my animations starts at (0,0), some finished quite far from there though.
What I'm doing so far is checking a property "isRootMotionAnimated" when I call SetAnimation(), the animation starts and enable/disable accordingly.
The problem occurs when I need to call AddAnimation, I can't seem to be able to get consistent start event callbacks then.
Right now I kinda workaround that taking out AddAnimation from my workflow and delaying SetAnimation accordingly

Thank you for providing this example !Harald wrote:Please let us know if this component helps, or just ask straight ahead if you have any questions. Unfortunately changes for the 4.0-beta release are keeping us a bit too busy for creating the example scene and skeleton for now.
I looked into it and while the compensation seems to make sense I can't actually get the SkeletonRootMotion to work, event without delta compensation

The skeleton rushes in the wrong direction and doesn't stop until I disable root motion.
Before these tests, I was using Pharan's root motion with good results, I was able to set root motion bone and "fixed bones" (fairly complex to setup though).
Could it be the problem ? :
With the new official root motion script I can only define a root motion bone.
My in spine editor setup looks like :
- Root
-- Root Motion Bone
--- Hips (and hips children bones)
--- IKLeg1
--- IKLeg2
--- .... more IKs
So yes, my root motion bone is not the Root, but a child bone containing everything else (we need to be able to rotate the skeleton without rotating the whole referential, but it could be bad practice ?)
1 year ago
- RemDust
- Posts: 223
Harald
TheRemDust wrote:The problem occurs when I need to call AddAnimation, I can't seem to be able to get consistent start event callbacks then.
Start
callback should be issued reliably right after a track has been started after being enqueued. There should be no difference to calling SetAnimation
. Are you sure that you are handling everything within the callback, and not delaying something to the next Update
or LateUpdate
call?Thanks for reporting and sorry for the troubles! I just checked the root motion script, and it indeed seems to run incorrectly when choosing a non-root bone asRemDust wrote:Before these tests, I was using Pharan's root motion with good results, I was able to set root motion bone and "fixed bones" (fairly complex to setup though).
Root Motion Bone
. This is indeed a bug, I have created an issue ticket here: https://github.com/EsotericSoftware/spine-runtimes/issues/1876We will let you know when it's fixed.
1 year ago
-
Harald - Posts: 3931
RemDust
Thank you for the quick reply Harald !
I'll wait for this fix then
Could you ping me when it's done ?
I'll wait for this fix then

Could you ping me when it's done ?
1 year ago
- RemDust
- Posts: 223
Harald
Yes, I will post here on the forum when it's done. I hope it can be completed today, otherwise it should be done the next few workdays next week.
---
@RemDust
The implementation has just been completed. The improved implementation should now support arbitrary bones as
New 3.8 and 4.0-beta unitypackages are available for download:
Spine Unity Download
Please let us know if this resolves your issue and now works as desired.
---
@RemDust
The implementation has just been completed. The improved implementation should now support arbitrary bones as
Root Motion Bone
. It now also respects Skeleton.ScaleX
and .ScaleY
and parent bone scale.New 3.8 and 4.0-beta unitypackages are available for download:
Spine Unity Download
Please let us know if this resolves your issue and now works as desired.
1 year ago
-
Harald - Posts: 3931
RemDust
Hi Harald, thank you for the light speed update.Harald wrote:The implementation has just been completed. The improved implementation should now support arbitrary bones asRoot Motion Bone
. It now also respectsSkeleton.ScaleX
and.ScaleY
and parent bone scale.
Please let us know if this resolves your issue and now works as desired.

1/ the fix seems to work really well. I'll let you know how stable it is moving forward.

2/ Using Rigidbody2D root motion is easy in the X axis, but I'm not too sure if I'm using it well on Y axis, mixing gravity and root motion animation seems like a arguably bad idea ^^

3/ Delta compensation is absolutely great ! I have just started playing with it but I think having an option to separate extrapolation on X and Y axis could be useful :
For instance, I have this case where the enemy jumps from a distance towards the player. Right now Delta Compensation overrides the Y jump component (as enemy and player are on the same ground) so he looks like he is sliding towords the player.
-> I guess enemy should use X Delta compensation but not Y, at least not right away. Actually in this case I think it would make sense that the enemy ignore Y Delta Compensation for the first part of the jump, where he is going upward and trigger Y compensation while he's going down.
Does this make sense somehow ?

1 year ago
- RemDust
- Posts: 223
Harald
You're welcome, thanks for reporting!
---
I have added functionality to separately apply delta compensation only for the X or Y component.
esotericsoftware.com/spine-unity-download
It will be integrated in the 4.0-beta branch soon.
Very glad to hear!RemDust wrote:1/ the fix seems to work really well. I'll let you know how stable it is moving forward.
I don't see a problem yet as it's just adding a root motion delta to the position of the rigidbody viaRemDust wrote:2/ Using Rigidbody2D root motion is easy in the X axis, but I'm not too sure if I'm using it well on Y axis, mixing gravity and root motion animation seems like a arguably bad idea ^^
rigidBody2D.MovePosition(new Vector2(transform.position.x, transform.position.y) + rigidbodyDisplacement);
So gravity should apply it's acceleration, and the rootmotion script should move the object an additional rootmotion-delta, both summing up additively. Admittedly I haven't thought this through completely though, did you encounter any problems?Good point! This is missing in the methodRemDust wrote:3/ Delta compensation is absolutely great ! I have just started playing with it but I think having an option to separate extrapolation on X and Y axis could be useful :
AdjustRootMotionToDistance
in the root motion script. I will add it to both SkeletonRootMotionBase.AdjustRootMotionToDistance
and the RootMotionDeltaCompensation
example component.If your animation starts at Y=0, has its high point at Y=1 and ends at Y=0 again, delta compensation of both X and Y should lead to the jump being adjusted only on the X axis and nothing changed on Y. I receive this at a local test setup. I wonder why you see a horizontal slide with Y motion being removed.For instance, I have this case where the enemy jumps from a distance towards the player. Right now Delta Compensation overrides the Y jump component (as enemy and player are on the same ground) so he looks like he is sliding towords the player.
Please note that delta compensation will scale your remaining animation so that the distance ofRemDust wrote:-> I guess enemy should use X Delta compensation but not Y, at least not right away. Actually in this case I think it would make sense that the enemy ignore Y Delta Compensation for the first part of the jump, where he is going upward and trigger Y compensation while he's going down.
position(now)
to position(last_frame)
fits the desired vector. So when you're at the first frame, it will scale the X and Y portions of the delta so that it reaches the target end point instead of the unscaled endpoint. There will be problems however if your target endpoint is at different Y and your animation does not change Y position from start to end, because no scaling can change a delta of 0.0 to e.g. 1.8. The easiest solution for this problem would be to create a jump animation that e.g. has an arc of Y values like: 0, 2, 1
. This way the whole arc will be scaled, when e.g. delta compensating the jump to land at Y=3 it will become 0, 6, 3
. Unfortunately this scaling solution does not yet solve the case for jumping down to e.g. -1 while using an upward animation, because it would then mirror the arc to a negative 0, -2, -1. Solutions to this problem could be- a) to enable delta-compensation later as you described, at the apex of the arc when moving downwards (although this will then look wrong, scaling only the downward half of the arc)
- b) an additional more complex delta compensation method to allow for such adjustment automatically.
---
I have added functionality to separately apply delta compensation only for the X or Y component.
A commit has just been pushed to the 3.8 branch and a new unitypackage is available for download here as usual:changelog.md wrote:Root motion delta compensation now allows to only adjust X or Y components instead of both. Adds two parameters toSkeletonRootMotionBase.AdjustRootMotionToDistance()
which default to adjusting both X and Y as before. TheRootMotionDeltaCompensation
example component exposes these parameters as public attributes.
esotericsoftware.com/spine-unity-download
It will be integrated in the 4.0-beta branch soon.
1 year ago
-
Harald - Posts: 3931
Return to Unity
- All times are UTC