Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extend a rope when the attached object shot from a position
#13
(29-09-2022, 02:29 PM)josemendez Wrote: 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:


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);


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.


Ok at the 100th experiment, this is sometimes working, sometimes not Gran sonrisa 70% working and very accurate...but sometimes just appears that gap. Interpolation is set to none...
But I don't know why. Gran sonrisa
Reply


Messages In This Thread
RE: Extend a rope when the attached object shot from a position - by lacasrac - 29-09-2022, 04:41 PM