09-11-2020, 09:53 PM
Hi again Jose!
I'm trying to detect if NO collision between different ropes happens at the Update, but don't understand how to do it..
Look, here's a short script (actually it is slightly changed CollisionHandler from obi samples):
It works nice and triggers when ropes collides. But how to detect when they don't?
I'm trying to detect if NO collision between different ropes happens at the Update, but don't understand how to do it..
Look, here's a short script (actually it is slightly changed CollisionHandler from obi samples):
Code:
public class RopeCollision : MonoBehaviour {
ObiSolver solver;
Obi.ObiSolver.ObiCollisionEventArgs frame;
void Awake(){
solver = GetComponent<Obi.ObiSolver>();
}
void OnEnable () {
solver.OnParticleCollision += Solver_OnCollision;
}
void OnDisable(){
solver.OnParticleCollision -= Solver_OnCollision;
}
void Solver_OnCollision (object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
foreach (Oni.Contact contact in e.contacts)
{
// this one is an actual collision:
if (contact.distance < 0.01)
{
ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle];
ObiSolver.ParticleInActor po = solver.particleToActor[contact.other];
if (pa.actor.gameObject != po.actor.gameObject)
{
Debug.Log("rope collides: " + pa.actor.blueprint.name + " " + po.actor.blueprint.name, pa.actor.gameObject);
}
}
}
}