27-01-2022, 02:08 PM
(27-01-2022, 01:44 PM)josemendez Wrote: You can make the sine wave relative to rope length, instead of relative to particle index. This way when particles separate due to stretching, the bulge won't stretch with them.
Simply accumulate the distance from one particle to the next, and use that instead of "i" in "Mathf.Sin(i + time)".
cheers,
Actually I didn't understand what do you mean exactly. I tried the code below and it didn't work.
Code:
float distance = Vector3.Distance(obiRope.GetParticlePosition(solverIndex), obiRope.GetParticlePosition(solverIndex - 1));
solver.principalRadii[solverIndex] = Vector3.one * (baseThickness + Mathf.Max(0, Mathf.Sin(distance + time) * bumpThickness));