Obi Official Forum
Help Initialize ObiCloth at 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: Help Initialize ObiCloth at Runtime (/thread-719.html)



Initialize ObiCloth at Runtime - OrangMosquito - 17-10-2018

Hi, I followed your tutorial for creating cloth at runtime. It didn't work, and it was visible in the inspector that the ObiCloth was uninitialized (there's no public method for initalizing at runtime). How do I go about this? Or might it be another problem?

Many thanks.


RE: Initialize ObiCloth at Runtime - josemendez - 17-10-2018

(17-10-2018, 09:16 AM)OrangMosquito Wrote: Hi, I followed your tutorial for creating cloth at runtime. It didn't work, and it was visible in the inspector that the ObiCloth was uninitialized (there's no public method for initalizing at runtime). How do I go about this? Or might it be another problem?

Many thanks.

Hi there,

There's an included example showing how to generate the mesh geometry/topology from scratch and initialize it at runtime. You'll find it in Obi/SampleScenes/RuntimeCloth. It uses the RuntimeClothGenerator.cs sample script to do its thing.

The method used to generate and initialize the cloth is GeneratePhysicRepresentationForMesh(). Note that this is a coroutine, so it must be called appropriately using StartCoroutine(). Calling it like a conventional method will have no effect.