• Unity
  • Root motion Mecanim

I'm searching for a solution for my animation which are NOT inplace. By example this is a "climb" animation, where the character holds and grap the ledge and go up and then stand on the platform. It's kinda impossible to do this via inplace animation with transform of the gameobject.

So the problem with no inplace animation is, that the pivot stays on the old position. Anyone some experience in this? I saw a few threads about root motion, but these are all for

SkeletonAnimation

but I'm using

SkeletonAnimator

because of Mecanim. I think the Root Motion feature from Unity itself will not work, because the exported Spine animations arent valide with the animations from unity.

Maybe the animation is done wrong. The root bone should follow the character right?

I hope someone can help me. If the informations arent enought, please tell me, so I can provide some more informations and gifs.

Thank you

Related Discussions
...
  • Bearbeitet

Good new: It is possible. We did it!

Bad news: I'm not sure how :wonder: Ill have a think

8 Tage später

Sounds interesting 😉

I think it's a must, because every game have such of animations and I'm not the only one who uses this. Maybe I'm the only one which uses this with Mecanim 😛


06 Dez 2016, 19:25


Nobody can help me?

Here are some gifs:

The skeleton gameobject (with

Animator

,

SkeletonAnimator

on it)

And here is the root which is fixed in spine to come with the character:

How can i do that the skeleton follows the root bone?

Probably the easiest way to do this would be, when the player grabs the ledge, to lock the player position to a specific position relative to the ledge. Eg, place the player where they will be when the ledge grab animation is complete. Then you design the ledge grab animation so it ends in that position.

Got to say that a agree, it's something that should be work on.
Root Motion is really important in complex animations ! 🙂

I think this wouldnt work Nate, because the character will "stumble" after animation end. And the transition (fade) is dynamic.

Of course it will work. Why would it stumble after the ledge grab animation? Make that animation finish in a neutral pose.

What transition is dynamic? You have a mix duration on entering the ledge grab animation? Then lock the player position relative to the ledge where the player is at the start of the ledge grab animation. At the end of the ledge grab animation, change the player position to be on top of the ledge, matching the pose at the end of the ledge grab animation.

tempted to make a rootmotion tutorial :nerd: :wonder:

  • Bearbeitet
BinaryCats schrieb

tempted to make a rootmotion tutorial :nerd: :wonder:

Knock yourself out dude ! 😃

I keep on thinking that Spine should take care about that someway.
I imagine something like this :
a checkbox on animation that lets you tell if root motion should be compensate, if yes, you select the bone reference that should be use to translate the root bone at the end of the animation.

Considering Spine environment it should be (I guess) really easy to implement. The hard part would be for Spine to pass that to the game engine world coordinates :think:

I somewhat agree, but the biggest argument for integrated rootmotion, is also the argument against integrated rootmotion

its the fact it takes 10 lines of code (different places)

BinaryCats schrieb

I somewhat agree, but the biggest argument for integrated rootmotion, is also the argument against integrated rootmotion

its the fact it takes 10 lines of code (different places)

Well, it sounds logical-like but it's really weird logic too :wonder:
If it's a big + for the software/users and if it's that easy to implement, I don't see any good reason not to do it !

And stop teasing us with your "it's so easy and short", share your code already ! >😃

Okay nate, the climb animation can work, but what about this?

That should be dynamic. Do the whole transition with unity, would be very hard.

Yep, agreed. Certainly root motion can be very useful, I was just pointing out that in some cases it isn't required.

So we can hope, Spine will receive root motion? 😛

Think you can whip something up, Pharan? 🙂

@Pharan, We added 3 vars to skeletonUtilityBone which we poll.

public Vector2 m_StoredBonePos = Vector2.zero;
public bool m_DisablePositionChange = false;
public bool m_DidUpdate = false;

Where a component which we add to the root bone sets DisablePositionChange to true

then in update we need store the bone pos and set back to 0

Doupdate()
{
...
   float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
            if ((bone.x != 0 || bone.y != 0))//store
            {
                m_DidUpdate = true;
                m_StoredBonePos = new Vector2(bone.x, bone.y);
            }
...
if (position)
                {
                    if (!m_DisablePositionChange)//check if it should move, if not reset it to 0
                        cachedTransform.localPosition = new Vector3(bone.x, bone.y, 0);
                    else
                    {
                        bone.x = 0;
                        bone.y = 0;
                    }
                }

}

But you also need to turn off mixing between animations for the rootbone.
TranslateTimeline.Apply:

override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
         Bone bone = skeleton.bones.Items[boneIndex];

if (boneIndex == 0)
                alpha= 1;
...

12 Dec 2016, 10:07


now you can just plug into the stored position, and move the character by that amount

@BinaryCats I saw in the other thread about Mecanim you said that you moved away from Mecanim right? Is root motion easier without it? I saw a few script in this forum about this. I decided to use Mecanim because we have a complex movement system and thought its easier do define this with Mecanim. If you say that its without easier, I'll give it a try to programm it.

partially, We turn rootmotion on and of with events. With mecanim you have to write code to listen to spine events yourself. (you get events through the mechanim system, but not all the data (its either float,int or string, not all)

I don't believe we ever used the rootmotion which mecanim and unity animator things provides for 3d models. and I'm not sure if it would ever work. other than the event stuff, it would just be the same.

My advice for mecanim would depend on your game, if its a big game, ild suggest not to use it (it becomes hard to manage), if its small there is no harm in trying to do it, even if you have to scrap it further down the line. - its important to note we where not at the start of the project when we integrated mecanim and that would have contributed to the nightmare

So, is there any nearly perfect running solution on this? With SkeletonAnimation or SkeletonAnimator (I think I can change if needed). I really need this, or how did all other Spine devs this? Cannot be the only one who need not "inplace" animations. Or there must be a solution to transform smoothly in Unity (inplace animation).