Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Is there a way to kill fluid particles on contact with a different fluid?
#3
Thanks for the help once again.

I'm trying a different approach for now, I'll try to actually kill the particles in contact with the dropper tip while applying suction.

I'm stuck already though, I can't get the index of those particles. I followed your instructions from the manual page about the trigger volume that reverses the gravity of the particles touching it, but I'm getting different results.


Code:
    void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        // calculate an acceleration that counteracts gravity:
        Vector4 antiGravityAccel = -(Vector4)solver.parameters.gravity * antiGravityScale * Time.deltaTime;

        var world = ObiColliderWorld.GetInstance();
        foreach (Oni.Contact contact in e.contacts)
        {
            // this one is an actual collision:
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;

                // if this collider is tagged as "zero gravity":
                if (col != null && col.gameObject.CompareTag("zeroGravity"))
                {
                    // get the index of the particle involved in the contact:
                    int particleIndex = solver.simplices[contact.bodyA];

                    // set the particle velocity:
                    solver.velocities[particleIndex] += antiGravityAccel;
                }
            }
        }
    }
}



I'm getting a ton of collisions from the solver, but apparently all of them are untagged even though my dropper has tags on the rigidbody and also on the trigger colllider. I also tried to directly compare the colliderbase gameobject reference with the dropper gameobject that has the trigger collider on it, but that never produces a match either. It looks like some contacts are simply missing from collisioneventargs.
Reply


Messages In This Thread
RE: Is there a way to kill fluid particles on contact with a different fluid? - by locque - 05-05-2022, 10:56 AM