(29-09-2022, 01:48 PM)lacasrac Wrote: where particlesIndex is
Code:
var particleIndex = rope.solverIndices[rope.elements[rope.elements.Count - 1].particle2];
That line doesn't make any sense, you're indexing the solverIndices array using the index of particles in the solver. For a single rope, this might work most of the time (even though particle order in the solver is undefined) but when there's more than 1 rope in the solver this will result in an out of bounds exception at runtime, because there's more particles in the solver than there are in a single actor.
Elements contain indices of particles in the
solver, not the actor. Quoting the
manual:
Quote:Each element in the array contains the indices of two particles in the solver: particle1 and particle2.
Particle groups however, reference particles in the actor (see:
http://obi.virtualmethodstudio.com/manua...ments.html) since -unlike elements- they do exist even if the actor is not being simulated by a solver.
So if you wish to retrieve the last particle in a rope and create a particle group out of it, you need to do this:
Code:
// retrieve the solver index of the last particle in the rope:
var solverIndex = rope.elements[rope.elements.Count - 1].particle2;
// find out the index of that particle in the rope:
var particleIndex = rope.solver.particleToActor[solverIndex].indexInActor;
// add it to the group:
group.particleIndices.Add(particleIndex);
(29-09-2022, 01:48 PM)lacasrac Wrote: It is working as I see, but always have a very big gap between the body part and the rope's end
Make sure the particle is placed at the correct position at the time of creating the attachment (note that attachments do not teleport the particles in the group to any specific position, they keep their current positions relative to the object they're attached to), and that no collisions are taking place between the rope and the body part.
Also keep in mind that using
interpolation in the solver will introduce a 1-frame delay in rendering, so unless your rigidbodies are also using interpolation you should set this setting to "none". Otherwise the rope will lag behind the rigidbodies it is attached to.