05-09-2022, 01:49 PM
(05-09-2022, 01:40 PM)josemendez Wrote: Hi!I was doing silly experiments I added the wrong code I added the wrong code. Sorry
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++;
}
}
}
}
counter runs but returns a number greater than 400 particles