Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  cloth-rope collision
#1
Hi!
It's possible to detect cloth-rope collisions? I have a cloth that simulates a piece of tissue and i would be able to create a needle with a thread that penetrates the cloth. In so doing, I'm not able to detect the particle collisions between the two. Am I doing something wrong?
Reply
#2
(21-04-2022, 10:31 AM)maygdirf Wrote: Hi!
It's possible to detect cloth-rope collisions? I have a cloth that simulates a piece of tissue and i would be able to create a needle with a thread that penetrates the cloth. In so doing, I'm not able to detect the particle collisions between the two. Am I doing something wrong?

Hi there,

Collisions between actors (rope and cloth, for instance) should happen automatically by default, unless you have changed the collision filters in either actor to specify otherwise.

You talk about "detecting the particle collisions", so I take it you're using a script to detect the contacts at runtime? can you share the script you're using?
Reply
#3
(21-04-2022, 10:37 AM)josemendez Wrote: Hi there,

Collisions between actors (rope and cloth, for instance) should happen automatically by default, unless you have changed the collision filters in either actor to specify otherwise.

You talk about "detecting the particle collisions", so I take it you're using a script to detect the contacts at runtime? can you share the script you're using?
Code:
private void Awake()
    {
        solver = this.GetComponentInParent<ObiSolver>();
    }

    private void OnEnable()
    {
        solver.OnCollision += Solver_OnCollision;
    }

    private void OnDisable()
    {
        solver.OnCollision -= Solver_OnCollision;
    }

    public void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        foreach(Oni.Contact contact in e.contacts)
        {
            ObiColliderBase collider = ObiColliderWorld.GetInstance().colliderHandles[contact.bodyB].owner;

            if (collider.CompareTag("Rope") && collider != null)
            {
                int particleIndex = solver.simplices[contact.bodyA];
                if (!(contactParticles.Contains(particleIndex)))
                    AddIndex(particleIndex, e);


                stitcher.AddStitch(particleIndex, solver.simplices[contact.bodyB]);
                stitcher.PushDataToSolver();
            }
This is part of my code. I would like to use the stitcher to attach the two obi actors. I think that something stupid is wrong in this code but I don't know what. Thanks for the help!
Reply
#4
You're subscribed to solver.OnCollision, instead of solver.OnParticleCollision. So your code is looking at the collisions between particles and colliders, not particle-particle collisions. Sonrisa

cheers!
Reply
#5
(21-04-2022, 11:21 AM)josemendez Wrote: You're subscribed to solver.OnCollision, instead of solver.OnParticleCollision. So your code is looking at the collisions between particles and colliders, not particle-particle collisions. Sonrisa

cheers!
Nice! I'm stupid  Gran sonrisa

But the subscription to the Solver_OnCollision function remains the same?
Reply
#6
(21-04-2022, 01:47 PM)maygdirf Wrote: But the subscription to the Solver_OnCollision function remains the same?

In C#, the name of the function subscribed to an event can be any you like. Solver_OnCollision is the one that Visual Studio automatically creates for you, but you could name it “MyColourfulFunction” and it would be fine Sonrisa
Reply
#7
(21-04-2022, 02:30 PM)josemendez Wrote: In C#, the name of the function subscribed to an event can be any you like. Solver_OnCollision is the one that Visual Studio automatically creates for you, but you could name it “MyColourfulFunction” and it would be fine Sonrisa
Yes, of course. I meant, like the one I have written in the code above! Ahahah
Reply