- Editado
implement root motion in special way
I implement root motion in my action game in this way
(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?
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.
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.
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
glad to hear that! and hope my solution can help others who need root motion.
We can gladly announce that root motion support has arrived for SkeletonAnimation
, SkeletonMecanim
and SkeletonGraphic
! 8)
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. :nerd:
From the Changelog:
Added Root Motion support for
SkeletonAnimation
,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
Harald escribióWe can gladly announce that root motion support has arrived for
SkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
! 8)You can download the updated 3.8 spine-unity unitypackage here as usual:
Spine Unity DownloadWhile the spine-unity documentation sections are currently being updated with the new feature, I'm sure you'll figure it out. :nerd:
From the Changelog:Added Root Motion support for
SkeletonAnimation
,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
:fiesta: Most exciting news to me. Thanks Harald !
You're welcome, very glad it's finally done!
Harald escribióWe can gladly announce that root motion support has arrived for
SkeletonAnimation
,SkeletonMecanim
andSkeletonGraphic
! 8)You can download the updated 3.8 spine-unity unitypackage here as usual:
Spine Unity DownloadWhile the spine-unity documentation sections are currently being updated with the new feature, I'm sure you'll figure it out. :nerd:
From the Changelog:Added Root Motion support for
SkeletonAnimation
,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
Hi, Harald
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.
Thanks for sharing this great idea, this would indeed be a very nice addition! We could easily provide 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.
Harald escribióThanks for sharing this great idea, this would indeed be a very nice addition! We could easily provide
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.
Hi, again
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.
yinmo escribió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.
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 name Root Motion Scale X/Y
.
yinmo escribió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.
We will add some methods to retrieve the total root motion distance for an animation, I have created an issue ticket here:
[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.
Harald escribióyinmo escribió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.
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 name
Root Motion Scale X/Y
.yinmo escribió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.
We will add some methods to retrieve the total root motion distance for an animation, I have created an issue ticket here:
[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.
Good to know, thanks a lot
The additional methods and parameters have been added.
From the changelog:
Added
Root 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);
.
New 3.8 unitypackages can now be downloaded here as usual:
Spine Unity Download
We hope you like it! :nerd: Please let us know whether the additions satisfy your requirements for your use cases.
Here is an additional inofficial example Component that shows how AdjustRootMotionToDistance()
can be used to compensate root motion to the position of a Transform.
Harald escribióThe additional methods and parameters have been added.
From the changelog:
Added
Root 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);
.New 3.8 unitypackages can now be downloaded here as usual:
Spine Unity DownloadWe hope you like it! :nerd: Please let us know whether the additions satisfy your requirements for your use cases.
Here is an additional inofficial example Component that shows how
AdjustRootMotionToDistance()
can be used to compensate root motion to the position of a Transform.
Wow, that`s way faster than I thought, impressive speed.
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.
You're welcome, glad it works as desired!
Regarding the clip name: please query it from SkeletonData:
Animation animation = skeletonData.FindAnimation(animationName);
Harald escribióYou're welcome, glad it works as desired!
Regarding the clip name: please query it from SkeletonData:
Animation animation = skeletonData.FindAnimation(animationName);
Thanks a lot
Hello Root Motion lovers :nerd:
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 ! :grinteeth:
Thanks !!
RemDust escribió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.
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 the Start
and Complete
callbacks: do your animations start at position (0,0)?
RemDust escribió2/ Delta compensation looks like a very nice feature but an actual exemple would be very helpful for beginners ^^
Good point. I have created an issue ticket here:
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.