17-12-2021, 11:09 AM
(This post was last modified: 17-12-2021, 11:09 AM by josemendez.)
Hi there!
Answered to your email, and sent you a fixed version of your script. The issue is that you were not flagging the constraints dirty when adding or removing colliders. I'm pasting my answer here for reference too:
In the Rope.cs file, you're creating a rope and placing a couple pin constraints manually at its ends. You're passing the "from" and "to" colliders to it. When a pin constraint is created, the current indices of the colliders you pass to it are stored in the solver, since the solver deals with particle and collider indices. If colliders are later created or destroyed, these indices might change so you need to flag the constraints as dirty.
When using attachments this is handled automatically, but if you're managing pin constraints manually you must take care of flagging them dirty when necessary, so they're rebuilt. Check the manual's "Scripting constraints" page, specifically "Adding/Removing constraints":
http://obi.virtualmethodstudio.com/manua...aints.html
I've modified your Rope script to account for this.
Answered to your email, and sent you a fixed version of your script. The issue is that you were not flagging the constraints dirty when adding or removing colliders. I'm pasting my answer here for reference too:
In the Rope.cs file, you're creating a rope and placing a couple pin constraints manually at its ends. You're passing the "from" and "to" colliders to it. When a pin constraint is created, the current indices of the colliders you pass to it are stored in the solver, since the solver deals with particle and collider indices. If colliders are later created or destroyed, these indices might change so you need to flag the constraints as dirty.
When using attachments this is handled automatically, but if you're managing pin constraints manually you must take care of flagging them dirty when necessary, so they're rebuilt. Check the manual's "Scripting constraints" page, specifically "Adding/Removing constraints":
http://obi.virtualmethodstudio.com/manua...aints.html
Quote:After you've added or removed particles/colliders, you will need to call actor.SetConstraintsDirty(). This rebuilds all solver batches of the given constraint type.
I've modified your Rope script to account for this.