• Unity
  • Animate only a part of the character

Hello,
On my game, I want to add a gadget to the hero. It is a belt (+backpack) with custom animation, but i want it to play his own animation, while the player play his own. how should i do that ?

i'm using unity Animator, my heroes have a lot of animations

Can i mix 2 objets in unity ? (for sorting issue, i cannot just put a belt object before the character)
Could i use a skin for the belt, and make it move his own animation on another Layer on the animator ?

Related Discussions
...
  • Uređeno

Are you using the SkeletonMecanim component with an animation Controller? Then having the belt animation on a separate animation layer should be the way to go.

If you are using SkeletonAnimation, you could use tracks at index 1 for the belt animation:

int trackIndexBelt = 1;
skeletonAnimation.AnimationState.SetAnimation(trackIndexBelt, beltAnimation, loop);

Alternatively, you could deal with sorting by adding a SkeletonRenderSeparator component, as shown in the Spine Examples/Other Examples/SkeletonRenderSeparator example scene. It demonstrates how you can split one skeleton into multiple render parts for depth sorting and rendering of other elements between them. However I would rather recommend using animation tracks or layers as described above.

Harald wrote

Are you using the SkeletonMecanim component with an animation Controller? Then having the belt animation on a separate animation layer should be the way to go.

If you are using SkeletonAnimation, you could use tracks at index 1 for the belt animation:

int trackIndexBelt = 1;
skeletonAnimation.AnimationState.SetAnimation(trackIndexBelt, beltAnimation, loop);

Alternatively, you could deal with sorting by adding a SkeletonRenderSeparator component, as shown in the Spine Examples/Other Examples/SkeletonRenderSeparator example scene. It demonstrates how you can split one skeleton into multiple render parts for depth sorting and rendering of other elements between them. However I would rather recommend using animation tracks or layers as described above.

I am using an Animator on unity (with the skeleton Animator for spine model)

I am not sure I understand the part

skeleton Animator for spine model

correctly, but I asume you are using the Mecanim-based SkeletonAnimator component, so you are using the old Spine-Unity runtime 3.6 (or earlier), in 3.7 and later the component is called SkeletonMecanim.

If the above is correct, then you should be able to add a second layer in the animation controller window for the belt animation, as described in my previous post.

Thank you 🙂

No problem 🙂