Hoghren

Greetings,

At the moment I'm working on a character that needs to be able to switch armor and weapons independently in Unity. What is the best way to do this? I'm looking at skin tutorials at this moment, but can you use multiple skins at the same time?
Hoghren
Posts: 14

Nate

A skeleton has a default skin and a skin. To find an attachment, Skeleton setAttachment looks in the skin, if not found there it then looks in the default skin. By default, the default skin contains the attachments that are not under any skin placeholders in Spine and therefore always available no matter which skin is set. Typically application code only sets the skin and not the default skin. You can create a new skin and add the attachments from multiple other skins.
User avatar
Nate

Nate
Posts: 7532

Hoghren

I'm still confused on how skins work. I've made a skin under the skin tab for a hat 2 and I've added a skin placeholder under a slot for a hat. I can only attach one image to the skin placeholder for hat 2. If I look at Unity I can only see the default hat.
Hoghren
Posts: 14

Erikari

Hey Hoghren, so far you made things right, what you can do is create a new skin, then look at that same skin placeholder you made, it should be empty in the new skin, this is where you can insert a new attachment (maybe try attaching a hat in a different color to test it). If you switch skin you'll see the old hat in there instead.
User avatar
Erikari

Erikari
Posts: 636

Pharan

Hello!
For equip and customization systems, people have been using something we call "Mix and Match".

I've documented the recommended steps for it for the most part here: https://github.com/pharan/spine-unity-docs/blob/master/Mix-and-Match.md
The doc is a work in progress so feel free to give us feedback about what's not clear.
User avatar
Pharan

Pharan
Posts: 4444

Hoghren

Thanks for all the help! I got most of it working now, but I have another question. If I animate the clothes of a character and I switch to a skin with damaged clothes, is there a way to keep the meshes/animations working? Or do I need to animate everyhing a second time?
Hoghren
Posts: 14

Pharan

No need to animate it multiple times.
Spine has a feature called Linked Meshes and it allows meshes with different backing images to share the same shape, weights and deform animations.

You can also generate these at runtime if you use Unity. At runtime, they're not a special type but just a MeshAttachment with a specific setup.
User avatar
Pharan

Pharan
Posts: 4444

Hoghren

I tried using the Linked Meshes, but the animations arn't working when I switch skins
Hoghren
Posts: 14

Pharan

It should, and does under normal circumstances.
Can you help us diagnose the problem? How were you creating the linked meshes?
User avatar
Pharan

Pharan
Posts: 4444

Hoghren

I already have a project with a character, multiple skins for different clothing and animations. I've applied Linked Meshes on all my meshes in the setup and now the mesh animations in the other skins have stopped working.

I've created the Linked Meshes by selecting a mesh and pressing the Linked Mesh icon at the bottom of the tree. The Mesh Icon changed to an atom like icon.
Hoghren
Posts: 14

Erikari

When you say:
Hoghren wrote:and now the mesh animations in the other skins have stopped working.
Do you mean the animations that those meshes had before, that are not related to the linked mesh, or the linked mesh animation?
In the first case this behaviour is to be expected, since you're replacing a mesh with another one that will be connected to the other linked meshes in the same slot, while in the second case, if you took them out of the same slot, they would stop being linked meshes.
Further information here: http://esotericsoftware.com/spine-meshes#Linked-meshes
User avatar
Erikari

Erikari
Posts: 636

Hoghren

The Linked Mesh animation is fine, it's just that the other animations I made in other skins before I applied the Linked Meshes have stopped working. All the attachments are grouped in the same skin.

For example, I've animated a cape in skin 1 and made that cape a linked mesh. Now I switch to skin 2 with the battle damaged cape version and it does nothing.
Hoghren
Posts: 14

Erikari

So, if I understood correctly:
- you have both normal meshes and linked meshes in the same slot
- you made animations for the normal meshes
- you made animations for the mesh that you turned into a linked mesh
- your linked meshes are in a skin placeholder, and your meshes are in a different skin placeholder, but both inside the same slot
- you did not replace the meshes with linked meshes by editing the path of the linked meshes and placed those in the skin placeholder of the meshes with animations
- you did not change the visibility of a skin placeholder in setup mode when you created the new linked mesh making the linked mesh skin placeholder visible instead of the mesh skin placeholder
So you should have two skin placeholders, and the mesh skin placeholder active in order to see both the animations of the meshes and have a backup with the linked mesh;
But the correct thing to do would be to change the path of the children linked meshes so that they show the old meshes images, and replace the old meshes with the new linked meshes inside their skin placeholders.
Does this match your situation?

---

But you wrote:
All the attachments are grouped in the same skin.
You can't have more than one linked mesh of the same element in the same skin visible at the same time. They are meant to be used across different skins. If you activate one and it is in the same slot of the other linked mesh, then the other can only be visible if you turn off the first.
If at the beginning of the animation you set visible the second one, you should be able to see it.

If this is neither the case,
Could I see the structure please?
User avatar
Erikari

Erikari
Posts: 636

Hoghren

This is my structure for the tabard: https://media.giphy.com/media/3ov9jEmOrVMnmR2hDa/giphy.gif

I made animations for the linked mesh tabard and when I switch skins to the dmg tabard it doesn't have animations.
Hoghren
Posts: 14

Erikari

The Dmg Tabard is not a linked mesh, therefore it can't have the same animations of the linked mesh.
you need to:
1. duplicate the linked mesh
2. move it so that is replaces the dmg tabard
3. change the path of the linked mesh to point at the dmg tabard image path
and then it should work.
User avatar
Erikari

Erikari
Posts: 636

Hoghren

It's working, thanks for all the help!
Hoghren
Posts: 14

Erikari

\(ºvº)/ great! glad to hear it worked!
User avatar
Erikari

Erikari
Posts: 636


Return to Editor