Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spawning Particles on cloth sim
#2
(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]
Reply


Messages In This Thread
Spawning Particles on cloth sim - by reuko - 08-06-2021, 02:53 PM
RE: Spawning Particles on cloth sim - by josemendez - 09-06-2021, 08:50 AM
RE: Spawning Particles on cloth sim - by reuko - 10-06-2021, 12:03 PM
RE: Spawning Particles on cloth sim - by reuko - 11-06-2021, 04:12 PM
RE: Spawning Particles on cloth sim - by reuko - 21-06-2021, 04:51 PM