Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How can i detect if two ropes are twisted
#5
(30-06-2020, 07:43 AM)josemendez Wrote: Hi there,

Yes, using particle contact callbacks would be a good start. You should subscribe to the solver's OnParticleCollision event. See:
http://obi.virtualmethodstudio.com/tutor...sions.html

You can increase the amount of substeps (in the ObiFixedUpdater) and/or distance constraint iterations (in the ObiSolver) to increase simulation quality. Take a look at this manual page, it explains how the simulation works in detail and how iterations/substeps affect it:
http://obi.virtualmethodstudio.com/tutor...gence.html
Code:
private void OnEnable()
    {
        obiSolver.OnParticleCollision += Solver_OnCollision;     
    }

void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        Oni.Contact[] contacts = e.contacts.Data;
        for (int i = 0; i < e.contacts.Count; ++i)
        {
            Oni.Contact c = contacts[i];
            // make sure this is an actual contact:
            if (c.distance < 0.01f)
            {
                ObiSolver.ParticleInActor pa = obiSolver.particleToActor[c.particle];
                Debug.Log($"collide with { pa.actor.name}");
            }
        }
    }

Hi i use this function to detect collision between 2 ropes. The debug log returns results when each particle of a single rope collides with itself or with other particles belong to that same rope. The two ropes do not twist themselves yet. Is my code the right way to do it ? What I want to achieve is if Rope A collides with Rope B, I want to detect Rope B only. I dont want to detect if particle of Rope A has collided with itself.

Another question, how do I set two ropes and more ropes twist them selves as a default state when the game starts ? I do not want to create and edit every single rope. Is there any way to create a knot in edit mode and save that state into play mode ?
Reply


Messages In This Thread
RE: How can i detect if two ropes are twisted - by rand123 - 01-07-2020, 07:42 AM