Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Attaching a rope and updating position multiple times
#3
Hi!

This bit is wrong:

Code:
// get the particle index of the first particle in the group
var particleIndex = particleAttachment.particleGroup.particleIndices[0];

// set the position of that particle to the attachment target
_solver.positions[particleIndex] = _solver.transform.InverseTransformPoint(attachmentTarget.position);

You're using the particle index in the blueprint as if it were a particle index in the solver. Once you add more than 1 rope to the solver, these cease to be the same, so your code is effectively always setting the position of particles in the first rope.

To retrieve the index of a particle in the solver, you must use the actor's solverIndices array. This maps from actor/blueprint index to solver index. See: http://obi.virtualmethodstudio.com/manua...icles.html

Quote:Actor particle indices run from 0 to the amount of particles in that actor. However, since particle data for an actor might be scattered across the solver arrays (see architecture), you need to map from actor index to solver index. You can map from actor particle indices to solver particle indices using the actor's solverIndices array.

Should be like this:

Code:
// set the position of that particle to the attachment target
_solver.positions[_rope.solverIndices[particleIndex]] = _solver.transform.InverseTransformPoint(attachmentTarget.position);
Reply


Messages In This Thread
RE: Attaching a rope and updating position multiple times - by josemendez - 28-02-2024, 08:17 AM