This... is a pain in the arse.
We have a situation where we want to use a body part of one character, and use it as a weapon for another. e.g. you can wack enemies with another enemies leg.
One solution might be to make a skin/animation for each enemy in the player file, which would equip the correct graphic, depending on what enemy's leg is being used.
the problem is we have a lot of enemies!
So I thought I would try to take the leg attachment from the enemy, and place it under a players slot. This would mean there would be no duplicate images in the data, and less work in spine ( I wouldn't have to drag all the enemies legs(and more) into the player file, setting skins and stuff)
This code works fine for region attachments.
public void SetSlotImage(Spine.Attachment a)
{
Spine.ExposedList < Spine.Slot > slots= m_Animation.skeleton.slots;
int s1 = 0, s2 = 0;
for (int i = 0; i < slots.Items.Length; i++)
{
if (slots.Items[i].data.name == "Weapon")
{
s1 = i;
break;
}
}
Spine.RegionAttachment reg = a as Spine.RegionAttachment;
slots.Items[s1].Attachment = reg;
}
It works mostly as expected.
However, the problem comes with Meshes/Wieghted mesh. I really would like them to be a region attachment, as I plan on having a dummy weapon attachment, which would have the correct transforms.
Is there a good way of doing this? has it been done before?