Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  'ObiCollider' does not contain a definition for 'idToCollider'
#6
(23-10-2020, 11:39 AM)josemendez Wrote: Works just fine for me, can you share the exact code you're using?
Code:
[RequireComponent(typeof(ObiSolver))]
public class CollisionEventHandler : MonoBehaviour
{

    ObiSolver solver;
    public int counter = 0;
    public Collider targetCollider = null;
    Obi.ObiSolver.ObiCollisionEventArgs collisionEvent;

    HashSet<int> particles = new HashSet<int>();

    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)
    {
        HashSet<int> currentParticles = new HashSet<int>();

        var world = ObiColliderWorld.GetInstance();
        foreach (Oni.Contact contact in e.contacts)
        {
            // this one is an actual collision:
            if (contact.distance < 0.00001)
            {
                ObiColliderBase collider = world.colliderHandles[contact.other].owner;
                if (collider != null)
                {
                    currentParticles.Add(contact.particle);
                }
            }
        }

        Debug.Log(currentParticles.Count);
        particles.ExceptWith(currentParticles);
        counter += particles.Count;
        particles = currentParticles;
    }
}

Here you are. Thank you very much.
Reply


Messages In This Thread
RE: 'ObiCollider' does not contain a definition for 'idToCollider' - by dabinzzang - 23-10-2020, 11:53 AM