(17-02-2026, 08:51 AM)josemendez Wrote: How are you setting the position of attached particles? your code shows how you detect collisions and how you create instances of StuckParticle, but not how you actually position particles during animation.
kind regards,
This is the portion:
Code:
protected virtual Vector3 GetTransformWorldPoint(StuckParticle sp)
{
return sp.target.TransformPoint(sp.localPoint) + sp.target.TransformDirection(sp.localNormal).normalized * surfaceOffset;
}sp.localPoint and sp.localNormal are correct contact points of the particle, but the TransformPoint when the root bone is rotated 180 degrees is wrong. It's heavily offset.
It then applies per frame here.
Code:
for (int i = 0; i < stuckParticles.Count; ++i)
{
var sp = stuckParticles[i];
if (sp.target == null) continue;
// Only skip CPU update for vertex-stuck particles if we're in GPU mode
if (useGPUPath && sp.isVertexStuck) continue;
Vector3 worldPoint = sp.isVertexStuck ? GetSkinnedMeshWorldPoint(sp) : GetTransformWorldPoint(sp);
Vector3 solverPoint = solver.transform.InverseTransformPoint(worldPoint);
solver.positions[sp.solverIndex] = solverPoint;
solver.prevPositions[sp.solverIndex] = solverPoint;
if (solver.velocities != null && sp.solverIndex < solver.velocities.count)
solver.velocities[sp.solverIndex] = Vector3.zero;
if (updateRenderablePositions && solver.renderablePositions != null && sp.solverIndex < solver.renderablePositions.count)
solver.renderablePositions[sp.solverIndex] = solverPoint;
solver.invMasses[sp.solverIndex] = 0;
if (solver.invRotationalMasses != null && sp.solverIndex < solver.invRotationalMasses.count)
solver.invRotationalMasses[sp.solverIndex] = 0;
}I've concluded unity does something weird with euler transforms when a bone with euler rotations is spun around 180 degrees. This causes some kind of transform offset when it should be accurate.
Undo the rotation and it works perfectly, attach the particle THEN rotate the root bone and it's fine. But attempt to attach the point post rotation it just gets wacky.
Don't rotate, perfectly acurate positions.
rotate root bone by animation 180 degrees, the resolved positions are all over the place, but the collision (represented in orange circles here) is fine.
