Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Controlling Particle Thickness at Runtime with Obi Rope
#1
Hey,

I tried looking into both the API and previous posts. It seems that this was possible at one point, but now there's no real information on it.

I want to create a cartoonish "bulge" effect in the an Obi Rope that animates through the rope, similar to old Loony Toon cartoons, as seen below:

[Image: c715f7f7c69b47f591e47f82752e31cb44d3401e_2_1024x524.png]

I've noticed that I can grab the ObiRope Component, access it's ObiPath, then it's thicknesses channel, and then the data itself as a list of floats, and I can modify them directly.

In order to apply the effect I was using the ObiPath's OnPathChanged Unity Event and invoking that.

Code:
[SerializeField]
private float _amplitude = 3f;
[SerializeField]
private float _frequency = 1f;
[SerializeField]
private float _phaseShift = 0f;

// ...etc.

private IEnumerator Pulsate()
{
    while (true)
    {
        if (_pulsating)
        {
            var t = Time.time;
            var pi = Mathf.PI;
            
            for (int i = 0; i < _thicknesses.Count; i++)
            {
                _rope.path.thicknesses.data[i] =
                    Mathf.Sin(1 + _amplitude * Mathf.Sin(2 * pi * _frequency * t - 2 * pi * i + _phaseShift));
            }
            _rope.path.OnPathChanged?.Invoke();
            
            yield return new WaitForSeconds(0.01f);
        }

        yield return new WaitForSeconds(0.5f);
    }
}

I was performing this in a coroutine under an always true while-loop and in a for-loop.

However, the results I'm getting don't appear to be right. It looks like the particles are updating randomly and infrequently. As in, the whole rope changes from thick to thin randomly and no part of it bulges differently. 

Video demo (Giphy Link):
[Image: giphy.gif]
Reply


Messages In This Thread
Controlling Particle Thickness at Runtime with Obi Rope - by wrcampbell1 - 29-04-2024, 12:05 AM