Obi Official Forum

Full Version: Spawning Particles on cloth sim
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I'm trying to see if it's possible to spawn particles (shuriken or vfx graph) on the surface/verts of an active simulating obi cloth/skinned cloth object. The reason for this is to have a lingering dust cloud/particle trail from the movement of the cloth sim. I'm able to get the particles to spawn in editor, but when entering play mode they disappear. Is there a way to do this with any particle system setup in unity + obicloth?

Thanks for your time!
(08-06-2021, 02:53 PM)reuko Wrote: [ -> ]Hello!

I'm trying to see if it's possible to spawn particles (shuriken or vfx graph) on the surface/verts of an active simulating obi cloth/skinned cloth object. The reason for this is to have a lingering dust cloud/particle trail from the movement of the cloth sim. I'm able to get the particles to spawn in editor, but when entering play mode they disappear. Is there a way to do this with any particle system setup in unity + obicloth?

Thanks for your time!

There's several ways to go about this.

If you're interested in vertices/cloth particles only, one is retrieving cloth particle positions at runtime and manually emitting your shuriken particles from these positions. This works for *any* kind of Obi actor. See:
http://obi.virtualmethodstudio.com/tutor...icles.html

If you want to use the mesh surface instead of individual particles, then there's two ways:

-If you're using regular (non-skinned) cloth, simply use shuriken's MeshRenderer shape mode like you would with any other object. Works out of the box and it's the simplest solution for regular cloth, since it requires no scripting.

-If you're using skinned cloth, you can't use shuriken's SkinnedMeshRenderer shape mode. This is because Obi bypasses SkinnedMeshRenderer, due to a limitation in how SkinnedMeshRenderers work. You can instead use Mesh shape mode, grab the cloth mesh at runtime (clothSkinnedRenderer.clothMesh), and feed it to the particle system.

Here's how a simple script to do this would look like:

Code:
using UnityEngine;
using Obi;

public class SkinnedClothParticleEmission : MonoBehaviour
{
    ParticleSystem ps;
    public ObiSkinnedClothRenderer clothRenderer;

    void Start()
    {
        ps = GetComponent<ParticleSystem>();
    }

    void Update()
    {
        if (ps != null && clothRenderer != null)
        {
            var sh = ps.shape;
            sh.enabled = true;
            sh.shapeType = ParticleSystemShapeType.Mesh;
            sh.mesh = clothRenderer.clothMesh;
        }
    }
}

Note that you will need to position the particle system at your character's root bone, otherwise the particles will be offsetted.

Here's the result (no material applied to particles, I'm just that lazy Lengua)
[Image: dUqEWOS.png]
Oh amazing breakdown Jose, thank you! I tried the non-skinned mesh particle setup similar to your approach here, but I'll try it again with your instructions. And i will also try the skinnedmesh approach for particle spawning as well, I'll let you know how it goes Sonrisa

By the way, is it possible to simulate the particles from VFX graph on either static or skinned meshes? I know skinned mesh particle support was added recently in unity 2021.1 but haven't tried it yet with obi cloth
Awesome, your setup above for static and skinned mesh particle spawning seems to have done the trick!

There seems to be an issue with the particles' velocity inheriting the cloth simulation motion (see dropbox link). When the skinned mesh moves around you can see that the particles move in the direction of the parent pivot, but as the cloth flings around the particles aren't following that motion, they sit in place. Is there a way to pass on the simulation motion to the inherit velocity of the dust particles?

video link: https://www.dropbox.com/s/js1ro47q3ma2n2...1.mp4?dl=0

Thanks again!!
(11-06-2021, 04:12 PM)reuko Wrote: [ -> ]Awesome, your setup above for static and skinned mesh particle spawning seems to have done the trick!

There seems to be an issue with the particles' velocity inheriting the cloth simulation motion (see dropbox link). When the skinned mesh moves around you can see that the particles move in the direction of the parent pivot, but as the cloth flings around the particles aren't following that motion, they sit in place. Is there a way to pass on the simulation motion to the inherit velocity of the dust particles?

video link: https://www.dropbox.com/s/js1ro47q3ma2n2...1.mp4?dl=0

Thanks again!!

Hi Reuko,


Shuriken particles inherit the velocity of the mesh, as a whole. They get it from differences in the transform position (something along the lines of:

Code:
velocity = (meshRenderer.transform.position - old position)  / Time.deltaTime;

However Shuriken knows nothing about cloth simulation, so it does not consider individual cloth particle velocities. This is something you'll have to implement yourself.

Obi lets you retrieve any property of each individual cloth particle, including its velocity. See:
http://obi.virtualmethodstudio.com/tutor...icles.html

Using that, you can determine the barycentric coordinates of each Shuriken particle when it is spawned, grab the velocity of the 3 corresponding cloth particles, and interpolate a velocity value for the Shuriken particle.
(10-06-2021, 12:03 PM)reuko Wrote: [ -> ]By the way, is it possible to simulate the particles from VFX graph on either static or skinned meshes? I know skinned mesh particle support was added recently in unity 2021.1 but haven't tried it yet with obi cloth

No idea, haven't touched VFX graph. My guess is that if it has support for skinned meshes/meshes, the setup will be similar to the ones I outlined in my first post.
Thanks again for the detailed reply Jose!

I'll be looking into the cloth simulation velocity inheritance this week, I'll let you know how it goes!

Much love  Corazón