• Runtimes
  • [Unity] Disadvantages of Spine Animation

I'm developer game on Unity Engine. Before I often using SM2 for create animation. But recent i'm trying use spine animation.
But i have a major problem that is spine animation can't attach a object from other atlas.
Example, i have a character atlas and a weapon atlas. One character can using many weapon. So i need to seperate the two atlas.
My idea is create skeleton animation for character using character atlas. Then respectively assigned weapons into character. My question how to implement it? and how to weapon can move via character animation? Before i used SM2 and because SM2 animation organized into small bone, i can implement this problem.
I look forward to receiving help from the people!

Related Discussions
...

It can already do this.

Wasn't there a sample of the multi-atlas setup in the Spine-Unity runtime folder? Was it removed?

Pharan

you can send to me URL of sample of multi-atlas setup?
Thanks for reply.

I'm pretty sure there was never an example of this. Someone should make a robust customizable character example heh

The dragon is an example of this.

Nate a écrit

The dragon is an example of this.

Eh not really. The dragon doesn't show how to grab a part from a different atlas or spine skeleton and add it to an existing one with code. The Spine Unity code-examples are really kinda sad right now - I'll probably whip a few up before Global Game Jam 🙂

I thought he just wanted to use two atlas pages. Should just be a matter of getAttachment and setting it on a slot in a different skeleton. The attachments are stateless, so shouldn't care that they were loaded in different skeleton datas.

Nate a écrit

I thought he just wanted to use two atlas pages. Should just be a matter of getAttachment and setting it on a slot in a different skeleton. The attachments are stateless, so shouldn't care that they were loaded in different skeleton datas.

Yea. There aren't any code examples for that in the Unity examples. The average "Uniteer" or "Uniphyte" will poke something in the inspector until it works or generally give up unless an explicit example is given lol; not to be offensive, but thats generally one of the "Perks" that Unity gives so it breeds that kind of behavior.

Nate a écrit

I thought he just wanted to use two atlas pages. Should just be a matter of getAttachment and setting it on a slot in a different skeleton. The attachments are stateless, so shouldn't care that they were loaded in different skeleton datas.

Example i had a skeleton animation with name "skeletonAnimation".
This code skeletonAnimation.skeleton.SetAttachment (slotName, attachmentName) work with attachmentName get from other different skeleton data.
Because a weapon will use for many character, i want divide two atlas character and weapon atlas. If you do it this way, game will be lighter and cost of maintain will save more time.
I hope that have a example can solve this problem.
Now, all examples of the spine are held weapons and character in an atlas. Actually this approach is not effective because it can not be updated separately for each character weapon.

Attachments are separate from the atlas.

Attachment attachment = skeletonAnimation.skeleton.GetAttachment(slotName, attachmentName);
otherSkeletonAnimation.skeleton.GetSlot(slotName).Attachment = attachment;

Attachment attachment = skeletonAnimation.skeleton.GetAttachment(slotName, attachmentName);
otherSkeletonAnimation.skeleton.GetSlot(slotName).Attachment = attachment;

Thanks for help. I will try to do by this way.


Nate a écrit

I have tried to do, but no results. Do you have example for that?
Here is my code:

public SkeletonAnimation daggerSkeletonAnimation;
    private SkeletonAnimation skeletonAnimation;
   // Use this for initialization
   void Start () {
        characterSkeletonAnimation = GetComponent<SkeletonAnimation>();
        if (daggerSkeletonAnimation.skeleton == null)
        {
            Debug.LogError("dagger skeleton is null");
        }
        Attachment rightHandWeapon = daggerSkeletonAnimation.skeleton.GetAttachment("right hand item", "dagger");
        if (rightHandWeapon != null)
        {
            // Assigned attachment for weapon slot but not effect.
            characterSkeletonAnimation.skeleton.FindSlot("weapon").Attachment = rightHandWeapon;
        }
   }

daggerSkeletonAnimation is weapon animation that referenced from the outside. After implement this code weapon not be assigned for character? Look forward the help. Thanks!

Mitch is working on some new features for spine-unity that should help you out.

For your code, I am guessing rightHandWeapon is null? Make sure the slot's attachment is being set to a non-null attachment.