After a short hiatus I got back into the project this week and I finally updated everything to 6.0.1 and made the necessary changes to my script. However, now I'm getting issues very similar to what tpaslou showed in his video, with the rope particle seeming to snap and pin to a position far from my hand, and respond poorly to being moved or rotated. This jittering and overreaction to rotation was present before 6.0 but the position at least remained close to the player hand. I meant to post this earlier and record a video but I could do that tomorrow if it helps.
Here is my current code, it's mostly the same as it was, though I may have made some mistake in updating versions:
Hope you can help, does this hold the record for longest Obi forum thread yet?
Here is my current code, it's mostly the same as it was, though I may have made some mistake in updating versions:
Code:
{
var batch = new ObiPinConstraintsBatch();
// retrieve the offset and size of the simplex in the solver.simplices array:
int simplexStart = solver.simplexCounts.GetSimplexStartAndSize(contact.bodyA, out int simplexSize);
int particleToGrab = 0;
Vector3 particlePosition = Vector3.zero;
// starting at simplexStart, iterate over all particles in the simplex:
for (int i = 0; i < simplexSize; ++i)
{
int particleIndex = solver.simplices[simplexStart + i];
var position = solver.positions[particleIndex];
if (Vector3.Distance(solver.transform.TransformPoint(position), contactCollider.transform.position)
< Vector3.Distance(particlePosition, contactCollider.transform.position)) // closest particle position
{
particleToGrab = particleIndex;
particlePosition = solver.transform.TransformPoint(position);
}
}
if (particleToGrab > 0) //Check particle is valid and prevents grabbing the particle attached to grappling hook
{
Vector3 positionWS = particlePosition;
Vector3 positionCS = obiCollider.transform.InverseTransformPoint(positionWS); // particle position from world to collider space
batch.AddConstraint(particleToGrab, obiCollider, positionCS, Quaternion.identity, 0, 0, float.PositiveInfinity);
batch.activeConstraintCount = 1;
newBatch = batch;
pinConstraints.AddBatch(newBatch);
canGrab = false;
// this will cause the solver to rebuild pin constraints at the beginning of the next frame:
rope.SetConstraintsDirty(Oni.ConstraintType.Pin);
}
}
Hope you can help, does this hold the record for longest Obi forum thread yet?