Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Fluid Particles interaction Script
#25
(23-11-2020, 05:09 PM)josemendez Wrote: I just realized that you were using Burst emission mode, which won't stop emitting even if speed is zero. I was testing with Stream mode instead.

Open ObiEmitter.cs, and change line 467 from this:

Code:
if (activeParticleCount == 0)

to this:

Code:
if (activeParticleCount == 0 && speed > 0)

That will make Burst emission stop when speed is set to zero.


Hi, yes that seemed to fix the issue! With that i have all my interactions between particles solved (unless i decide to change or add to the main mechaninc). But for now my last question is about particle collision with objects/player. Where do i have to put my script? On the object or the fluid? Collision is detected between particles and objects? I found this in an older post in here ;

Code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Obi;

[RequireComponent(typeof(ObiSolver))]
public class CollisionEventHandler : MonoBehaviour {

    ObiSolver solver;

   public Collider killer;

    void Awake(){
        solver = GetComponent<Obi.ObiSolver>();
    }

    void OnEnable () {
        solver.OnCollision += Solver_OnCollision;
    }

    void OnDisable(){
        solver.OnCollision -= Solver_OnCollision;
    }
    
    void Solver_OnCollision (object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        for(int i = 0;  i < e.contacts.Length; ++i)
       {
           if (e.contacts[i].distance < 0.001f)
           {

               Component collider;
               if (ObiCollider.idToCollider.TryGetValue(e.contacts[i].other,out collider)){

                   if (collider == killer){

                       ObiSolver.ParticleInActor pa = solver.particleToActor[e.contacts[i].particle];
                       ObiEmitter emitter = pa.actor as ObiEmitter;

                       if (emitter != null)
                           emitter.life[pa.indexInActor] = 0;
                       
                   }
               }
           }
       }
   }
}


I´m looking for a script that works the other way round, that destroys the object instead of the particles. Any help?
Big thanks!
Reply


Messages In This Thread
RE: Fluid Particles interaction Script - by JoseCarlos S - 26-11-2020, 01:39 PM