17-07-2020, 08:32 AM
(16-07-2020, 05:37 PM)anulagarwal Wrote:Basically this is attached on the Solver object, and the e.contacts.Count keeps fluctuating for some reasonCode: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);
}
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