Add cloth and runtime - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Add cloth and runtime (/thread-2319.html) |
Add cloth and runtime - renderlux - 17-06-2020 I'm trying to add ObiSkinnedCloth and reference skinnedClothBlueprint var gameObj = meshObject.AddComponent<ObiSkinnedCloth>(); gameObj.skinnedClothBlueprint = ScriptableObject.Instantiate(SourceBlueprint.instance.sourceTop); meshObject.AddComponent<ObiSkinnedClothRenderer>(); But I'm getting NullReferenceException: Object reference not set to an instance of an object I believe the problem is: gameObj.skinnedClothBlueprint = ScriptableObject.Instantiate(SourceBlueprint.instance.sourceTop); RE: Add cloth and runtime - josemendez - 17-06-2020 (17-06-2020, 03:54 PM)renderlux Wrote: I'm trying to add ObiSkinnedCloth and reference skinnedClothBlueprint Well, this can only mean SourceBlueprint, SourceBlueprint.instance or SourceBlueprint.instance.sourceTop are null. I can't possibly know which one. Try debugging your code by placing a breakpoint at that line, and check what's raising the null ref exception. RE: Add cloth and runtime - renderlux - 18-06-2020 Hi This looks like it works (no errors) Code: myMesh.AddComponent<ObiSkinnedCloth>(); and I create Solver in Start() Code: GameObject solverObject = new GameObject("solver", typeof(ObiSolver), typeof(ObiFixedUpdater)); But the physics don't work RE: Add cloth and runtime - josemendez - 18-06-2020 (18-06-2020, 10:12 AM)renderlux Wrote: Hi Is the cloth inside (the hierarchy of) a solver? It won't simulate otherwise. Does it have a ObiSkinnedClothRenderer component? the cloth mesh won't be updated according to the simulation if it doesn't. RE: Add cloth and runtime - renderlux - 18-06-2020 (18-06-2020, 10:14 AM)josemendez Wrote: Is the cloth inside (the hierarchy of) a solver? It won't simulate otherwise. Hi I'm adding the component : meshObject.AddComponent<ObiSkinnedClothRenderer>(); Do I need to do anything else? Like link ObiSkinnedCloth with ObiSkinnedClothRenderer ? RE: Add cloth and runtime - josemendez - 18-06-2020 (18-06-2020, 02:34 PM)renderlux Wrote: Hi Your cloth needs to be a child of the solver object. Can you share you entire cloth instantiation code? this way I can tell what's missing more easily. |