18-09-2023, 05:20 PM
(This post was last modified: 18-09-2023, 05:24 PM by josemendez.)
(18-09-2023, 02:44 PM)aderae Wrote:Code:private void ObiRopeLoaded(ObiActor actor, ObiActorBlueprint blueprint)
{
// load particle positions
for (int i = 0; i < ObiSolver.positions.count; i++)
{
if (i < ParticlePositions.Count)
{
ObiSolver.positions.SetVector3(i, ParticlePositions[i]);
}
ObiSolver.velocities.SetVector3(i, Vector3.zero);
}
ParticlePositions.Clear();
}
Hi,
This bit is completely incorrect. You're iterating trough all particles in the solver including inactive ones, and disregarding the order in which they appear in the rope. Might work purely out of luck, but most of the time this will result in wrong positions given to the particles and overall unpredictable behavior.
Each actor has a solverIndices array that contains the index of the actor's particles in the solver. So solver.positions[actor.solverIndices[0]] would be the position of the first particle in the rope, solver.positions[actor.solverIndices[1]] would be the position of the second particle, etc. The solver might have allocated space for 2000 particles, but if actor.solverIndices only has 20 entries, then only 20 of those particles are used. Note they might not be given consecutive indices in the solver, no guarantees are made about the order in which particles are allocated.
See:
http://obi.virtualmethodstudio.com/manua...icles.html
Using solverIndices to iterate trough all particles, it works just fine for me. Even then, setting all particle positions to zero also works fine, so there must be something else going on in your project. If you want, I can take a closer look at it if you send the project to support(at)virtualmethodstudio.com.
kind regards,