Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fluid Counter
#3
(05-09-2022, 01:40 PM)josemendez Wrote: Hi!

Your code doesn't make much sense: it iterates trough all contacts, and for all contacts against a collider in layer 7 (which I assume is the white cube in your image) it sets counter = solver.contactCount. So all your code is equivalent to just:

Code:
counter = solver.contactCount

Code:
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
     {
         var world = ObiColliderWorld.GetInstance();

         // just iterate over all contacts in the current frame:
         foreach (Oni.Contact contact in e.contacts)
         {
             // if this one is an actual collision:
             if (contact.distance < 0.01)
             {
                 ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
                 if (col != null && col.gameObject.layer == 7)
                 {
                     counter++;
                 }
             }
         }

}
I was doing silly experiments Sonrisa I added the wrong code I added the wrong code.  Sorry Triste 
counter runs but returns a number greater than 400 particles
Reply


Messages In This Thread
Fluid Counter - by 0hsyn1 - 05-09-2022, 01:04 PM
RE: Fluid Counter - by josemendez - 05-09-2022, 01:40 PM
RE: Fluid Counter - by 0hsyn1 - 05-09-2022, 01:49 PM
RE: Fluid Counter - by josemendez - 05-09-2022, 01:51 PM
RE: Fluid Counter - by 0hsyn1 - 05-09-2022, 01:58 PM
RE: Fluid Counter - by josemendez - 05-09-2022, 02:06 PM
RE: Fluid Counter - by 0hsyn1 - 05-09-2022, 02:10 PM