Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to detect number of particles in collision?
#7
(16-07-2020, 05:37 PM)anulagarwal Wrote:
Code:
  ObiSolver solver;
    bool isHit;

    Obi.ObiSolver.ObiCollisionEventArgs collisionEvent;

    List<Oni.Contact> c;
    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)
    {
      
       
        GameManager.instance.SetCompletion(e.contacts.Count);
      
    }
Basically this is attached on the Solver object, and the e.contacts.Count keeps fluctuating for some reason

contacts.Count will of course fluctuate over multiple frames, as some frames more particles will be in contact that in others depending on the situation. Not all particles will be in contact with all colliders all the time. You need to check for actual contacts by the way, not just speculative ones. For this, you need to make sure the contact distance is negative (or smaller than a small positive value). Check the sample in the docs:
http://obi.virtualmethodstudio.com/tutor...sions.html
Reply


Messages In This Thread
RE: How to detect number of particles in collision? - by josemendez - 17-07-2020, 08:32 AM