Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Obi Rope Pipe Water Flow Effect
#6
(27-01-2022, 02:08 PM)NorkQ Wrote: 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));

You need to accumulate distance as you go, not just grab the distance between the current particle and the previous one. Otherwise the sine value will be basically the same for every particle, instead of varying along the rope.

Like this:

Code:
float distance = 0;

        for (int i = 0; i < rope.solverIndices.Length; ++i)
        {
            int solverIndex = rope.solverIndices[i];

            if (i > 0)
            {
                int previousIndex = rope.solverIndices[i - 1];
                distance += Vector3.Distance(rope.solver.positions[solverIndex],rope.solver.positions[previousIndex]);
            }

            rope.solver.principalRadii[solverIndex] = Vector3.one * (baseThickness + Mathf.Max(0, Mathf.Sin(distance * bulgeScale + time) * bulgeThickness));
        }

I threw a "bulgeScale" multiplier in there, so that you can control the width of the bulges.
Reply


Messages In This Thread
Obi Rope Pipe Water Flow Effect - by NorkQ - 27-01-2022, 11:16 AM
RE: Obi Rope Pipe Water Flow Effect - by NorkQ - 27-01-2022, 01:40 PM
RE: Obi Rope Pipe Water Flow Effect - by NorkQ - 27-01-2022, 02:08 PM
RE: Obi Rope Pipe Water Flow Effect - by josemendez - 27-01-2022, 02:19 PM
RE: Obi Rope Pipe Water Flow Effect - by NorkQ - 27-01-2022, 04:57 PM