Obi Official Forum
Help Generate Tethers 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 Generate Tethers at Runtime (/thread-1614.html)



Generate Tethers at Runtime - Visitor245262 - 10-01-2020

Ive added pin constraints at runtime by using .GetFirstBatch() on ObiPinConstraints. But when I try to do a similar thing with tethers I cant get the reference for the ObiTetherConstraintBatch.

And will I have to use AddConstraint for each fixed particle to every other particle on the mesh?

Thanks.


RE: Generate Tethers at Runtime - josemendez - 10-01-2020

(10-01-2020, 07:56 AM)Visitor245262 Wrote: Ive added pin constraints at runtime by using .GetFirstBatch() on ObiPinConstraints. But when I try to do a similar thing with tethers I cant get the reference for the ObiTetherConstraintBatch.

And will I have to use AddConstraint for each fixed particle to every other particle on the mesh?

Thanks.

There's always a batch for pin constraints, even if there's no actual pins present. This is the only constraint type where this happens.

For all other constraints, you have to create and populate your own constraint batches. Assuming we're talking about Obi 5.0, you will have to make sure no two constraints in each batch reference the same particle. This is because all constraints in each batch are processed in parallel.

Nevertheless, both in Obi 4 and Obi 5 there's the GenerateTethers() function, that automatically creates and populates all tether batches for you. May I ask why do you need to generate tethers manually?


RE: Generate Tethers at Runtime - Visitor245262 - 10-01-2020

(10-01-2020, 08:03 AM)josemendez Wrote: There's always a batch for pin constraints, even if there's no actual pins present. This is the only constraint type where this happens.

For all other constraints, you have to create and populate your own constraint batches. Assuming we're talking about Obi 5.0, you will have to make sure no two constraints in each batch reference the same particle. This is because all constraints in each batch are processed in parallel.

Nevertheless, both in Obi 4 and Obi 5 there's the GenerateTethers() function, that automatically creates and populates all tether batches for you. May I ask why do you need to generate tethers manually?

Sorry, I should have mentioned I'm using an older version of Unity(5.6) on this project and its Obi 3.4. I have cloth thats getting pin constrained around a cylinder as it rotates fast, slow rotation is no issue. The cloth moves freely with no fixed particles before it gets constrained to the cylinder, but after it starts to wrap it will only wrap cleanly if there are tethers (I have tested it by manually setting it up). I might be able to work around it and have the particles fixed beforehand and modifying my setup. Thanks.


RE: Generate Tethers at Runtime - josemendez - 10-01-2020

(10-01-2020, 08:50 AM)Visitor245262 Wrote: Sorry, I should have mentioned I'm using an older version of Unity(5.6) on this project and its Obi 3.4. I have cloth thats getting pin constrained around a cylinder as it rotates fast, slow rotation is no issue. The cloth moves freely with no fixed particles before it gets constrained to the cylinder, but after it starts to wrap it will only wrap cleanly if there are tethers (I have tested it by manually setting it up). I might be able to work around it and have the particles fixed beforehand and modifying my setup. Thanks.

You can fix the particles you want to act as the tether anchors, generate tethers, and then un fix these particles. The tethers will stay in place.

Unless you want to get *very* specific about tether placement, this approach should be enough.