holymolar

Hello folks,

Been looking through forums for a while but haven't found an answer yet. Went through the mix and match examples and docs extensively too.

We're looking to add one smaller skeleton into another main one with bones (and hopefully anims too). Primarily we're in need of customizing the location of bones per attached (sub) skeleton. There'd be tons of these customizations and updates so can't really have them all in one rig. And we need to do it at run-time.

Perhaps I'm doing something wrong... Seen also the ability to add Skins, but doesn't seem to add materials and parts from a different skeleton. And also with the mix and match, have also noticed the new sprite must fit into the old sprite's width and height, which in this case is undesired.

Any ideas?

Tried AddAttachments and AddSkin
Seems to add attachment references though (but not materials, skeleton slots, etc.). Would like to be able to use the Mix and Match techniques on the sub-skeleton after its been added.
// skin from the primary skeleton
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
var templateSkin = skeletonData.FindSkin("default");

// skin from the second skeleton
var skeletonData2 = skeletonDataAttachment.GetSkeletonData(true);
var templateSkin2 = skeletonData2.FindSkin("default");


// expecting to place new bones, slots, image uvs, and materials
Skin collectedSkin = new Skin("Collected skin");
collectedSkin.Clear();
collectedSkin.AddAttachments(templateSkin);
collectedSkin.AddAttachments(templateSkin2);
skeletonAnimation.skeleton.SetSkin(collectedSkin);
skeletonAnimation.skeleton.SetSlotsToSetupPose();
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton);
The secondary rig structure (we intend to make it more complex, but this gets us going)
holymolar
  • Сообщения: 4

Harald

I assume that the recently added skin-bones are not an option for you, right? You could then add one skin including weapon-bones per weapon.

If you need to keep weapons as a separate skeleton:
Unfortunately, skeleton attachments are not supported yet. However, you can add the skeleton as a separate GameObject (attached to a bone of the main skeleton via a BoneFollower component) and have some constraints on the main skeleton place e.g. the hand bones according to the current weapon grip position. You could have a look at Spineboy's aim constraint setup (shown in the Spine Examples/Getting Started/4 Object Oriented Sample scene), which allows the weapon arm to be pointed at a cursor position.
Аватара пользователя
Harald

Harri
  • Сообщения: 1028


Вернуться в Unity