Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Detect specific rope collision.
#4
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):

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);
                }
            }
        }
    }
It works nice and triggers when ropes collides. But how to detect when they don't?
Reply


Messages In This Thread
Detect specific rope collision. - by flaurens - 05-10-2020, 08:45 AM
RE: Detect specific rope collision. - by flaurens - 05-10-2020, 12:18 PM
RE: Detect specific rope collision. - by Elegar - 09-11-2020, 09:53 PM
RE: Detect specific rope collision. - by Elegar - 11-11-2020, 12:16 PM
RE: Detect specific rope collision. - by Gauri7 - 04-07-2022, 11:57 AM
RE: Detect specific rope collision. - by Gauri7 - 04-07-2022, 02:12 PM
RE: Detect specific rope collision. - by Gauri7 - 05-07-2022, 09:33 AM
RE: Detect specific rope collision. - by Gauri7 - 06-07-2022, 12:20 PM
RE: Detect specific rope collision. - by Gauri7 - 08-07-2022, 09:35 AM