(08-08-2023, 03:16 PM)Alexander34 Wrote: Hello again. I need to make it so that the rope, when playing on the player animation of climbing on it, realistically behaved with respect to the points of contact. Clearly on the attached screenshot. How can I implement this with your Asset in the least costly and simplest way?
I can only think of creating a particle group on the fly, but that would be very costly
Why would it be costly to
create particle groups on the fly? they're a very small/simple object with a list of particles, and in the case of ropes they always contain just one index.
Code:
// Create the attachment:
var attachment = rope.gameObject.AddComponent<ObiParticleAttachment>();
attachment.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
attachment.target = bodyA.transform;
// Create a particle group and use it in the attachment:
var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
group.particleIndices.Add(particleIndex); // index of the particle in the rope
attachment.particleGroup = group;
You could also reuse the same particle group and just change the particle index: disable attachment, change particle index, re-enable attachment, in that order. This way you don't even have to allocate any memory at runtime, as you're reusing the same attachment/group.
There's another option too: note that dynamic attachments use pin constraints internally to couple particles and rigidbodies, so another option if you don't want to deal with groups/attachments is to create and manage your own pin constraints manually. Note this is a lower-level approach and considerably more complex. The manual contains information about how to create your own constraints at runtime:
http://obi.virtualmethodstudio.com/manua...aints.html
There's also a "GrapplingHook" sample scene included that shows you how to create pin constraints at runtime, see Obi/Samples/RopeAndRod/SampleResources/Scripts/ExtendableGrapplingHook.cs
kind regards,