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
#2
(29-04-2024, 12:05 AM)wrcampbell1 Wrote: 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:

Hi,

Obi includes an example of this exact use case, see the "Firehose" sample scene.


(29-04-2024, 12:05 AM)wrcampbell1 Wrote: 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.

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. 

This approach doesn't make any sense: you're modifying the blueprint, which is an asset that stores the initial data for the rope on disk. Once a rope is instantiated from a blueprint, they're no longer linked together: the rope won't reflect changes made to the blueprint unless you re-Genenerate() the blueprint, which is a very expensive operation as it involves essentially destroying all ropes using it and then creating them anew. So in a way, what you're doing is akin to modifying a .fbx mesh asset and reimporting it just to change mesh vertex positions.

Being a particle-based engine, all runtime data in Obi is stored as particles. You can read/write all per particle data at runtime using the particles API. For ropes, you also have access to elements which are strut/spring-like edges joining pairs of particles together.


let me know if I can be of further help,

kind regards
Reply
#3
I cannot thank you enough! I can't believe I didn't thoroughly check the samples section after pouring through the source code. 

I knew I was doing something terribly wrong, but I was desperate to get the solution. I felt like this tool just had to be able to do this trick, and sure enough, I was right! Just not about the method.

Also, to anyone who reads this, the Unreal Engine's closest equivalent of this tool (particle-based rope physics) is so much less useful and flexible. This tool is genuinely amazing. I just wish Obi Fluids worked on HDRP. 

Thanks again!
Reply