Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to remove particles at runtime
#1
Pregunta 
So I'm trying to have particles disappear when they collide with an object. I have tried three methods but all seem to cause the emitter to behave weird. When the particles collide with the object they do disappear but it seems like at a certain point (30 seconds in), particles just disappear as soon they emitted when I use either one of these methods.

Code:
    private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();
        foreach (Oni.Contact contact in e.contacts)
        {
            // look for actual contacts only:
            if (contact.distance < 0.01f)
            {
                var col = world.colliderHandles[contact.other].owner;
                if (col.tag == "Outlet")
                {
                    Debug.Log("Remove Particle");
                    if(method1)
                        emitter.solver.actors[0].DeactivateParticle(contact.particle);
                    else if(method2)
                        emitter.life[contact.particle] = 0;
                    else if(method3)
                        emitter.KillParticle(contact.particle);
                }
            }
        }
    }

Is there a standard way for removing specific particles when a collision takes place?
Reply


Messages In This Thread
Best way to remove particles at runtime - by ary1111 - 16-12-2020, 07:47 PM