Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Crash on adding and removing during runtime
#1
I have a skinned overcoat which it's bottom half use Obi to simulate cloth.
If I equip and unequip it enough times, unity editor crashes.

Works fine in edit mode, I can equip/unequip at will and it never crashes, but it crashes before the 5th equip in play mode

Sometimes it happens right after equiping/unequiping (webm)
Sometimes after equipping, the overcoat will not follow the model and crash soon afterwards (crash log)

webm (I am clicking a object finder window to equip/unequip the jacket): https://webmshare.com/LPWNr (the video stops when unity crashes)
crash log: https://pastebin.com/3QGUvSSb
Reply
#2
(19-01-2018, 01:55 AM)Guedez Wrote: I have a skinned overcoat which it's bottom half use Obi to simulate cloth.
If I equip and unequip it enough times, unity editor crashes.

Works fine in edit mode, I can equip/unequip at will and it never crashes, but it crashes before the 5th equip in play mode

Sometimes it happens right after equiping/unequiping (webm)
Sometimes after equipping, the overcoat will not follow the model and crash soon afterwards (crash log)

webm (I am clicking a object finder window to equip/unequip the jacket): https://webmshare.com/LPWNr (the video stops when unity crashes)
crash log: https://pastebin.com/3QGUvSSb

Hi,

There's lots of null reference exceptions in your log, all point to Obi.ObiClothProxy.Source_OnRemovedFromSolver.

This method is called when you set cloth.Solver to something different to what it previously had. It removes the cloth from its old solver before adding it to the new one.

Thing is, under no circumstance can the solver be null when calling this method. So the only possibility left is that you're destroying the ObiClothProxy's source (the ObiCloth component) before destroying the proxy itself, orphaning the proxy without notifying it first that the cloth has left the solver. This is however quite unexpected, I can't quite figure out any situation in which this could happen.

Can you please post the code used to equip/unequip, and a pic/explanation of the hierarchy structure of your characters?
Reply
#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
#4
Any news on this? Maybe you are still missing some information?
Reply
#5
(12-02-2018, 01:03 PM)Guedez Wrote: Any news on this? Maybe you are still missing some information?

Hi Guedez:

If you could provide a Unity package with the relevant code so that we can test/debug it it would be great. There's nothing wring at first sight with your code, but certain things (such as replacing joints by name) can be problematic depending on the exact order in which they're done, since Obi picks up all bone information at instantiation and it assumes bones aren't reassigned at runtime. Trying this and taking a close look at what happens might be the only way to determine the cause.

cheers,
Reply
#6
Although I didn't make a unitypackage, I've managed to confirm that it was the removal of bones after the solver was set that was the problem.
By having he Stitch method add the solver to the mesh only at the end of the method, it works flawlessly now
Reply