Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Crash on adding and removing during runtime
#3
Sorry I couldn't reply earlier.


Relevant Scripts:
DEBUG_EQUIPER: https://pastebin.com/YHTdhvyq
Sticher: https://pastebin.com/nbQwMkNA (Modified version from masterprompt's, original posted somewhere in this thread: https://forum.unity.com/threads/stitch-m...ter.16485/)


Relevant Object Info:
Character Hierarchy (Didn't extend the hands because it's a load of bones there): https://pasteboard.co/H3InnQ6l.png
Overcoat scripts (After it's equiped, the only difference between this and the prefab, is that the ObiSolver is null in the prefab, for some reason it's not saving it, probably because prefabs can't reference scene objects): https://pasteboard.co/H3InOGj.png
SkinnedMeshRenderer (In case it's relevant): https://pasteboard.co/H3IoW4p.png


What the codes do is as follow: 
The equiper waits for you to drop (or select one with the object picker) ItemClothDescriptor in one of it's slots  (it always show a empty slot, so you can always equip more stuff), the ItemClothDescriptor just store information about the item you are about to equip, like it's name, prefab, what slots it use, etc
Once you change the value on one of it's slots, it will either equip (if it was previously empty and you added something) or unequip otherwise.

Equiping a object means picking every bone (transform) referenced by it's SkinnedMeshRenderer and replacing it with the character's equivalent (through name matching), so that the clothing will always mimic the player's animation, regardless of what's being played. The old bones are deleted afterwards (this part is commented for now). The cloth gets then parented to the character.

Unequiping is easier, just delete all relevant objects (not the case of the overcoat, but some cloths like the scarf, have plenty of character joints to make them animate, those are moved to another hierarchy, so that they don't move with the character and have to rely on the character joints to stay in the right place)


In case it got skimmed over, the overcoat prefab (named jacket for some reason) does NOT have the ObiSolver set on it, it is only set after it have been instanced. The ObiSolver which is set to the overcoat is the same which is set on the DEBUG_EQUIPER. Not sure how relevant this is, but that's the most that the code interacts with the ObiCloth system

'jointParent' is where the character joints go to, so it's not relevant to this issue
Reply


Messages In This Thread
RE: Crash on adding and removing during runtime - by Guedez - 20-01-2018, 12:58 AM