Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Check for collision of last particle in rope
#1
Hi again,







I need a way to check if the last particle in the rope (i.e. end of the rope) has collided with an object.



I understand the last point in the rope can be obtained by elements but I'm not sure how to check for the actual particle.




If that last particle hits an object I need to assign that object as an ObiParticleAttachment.target.



Here's what I have so far.. any hints? Hoping to get this figured out before the holidays Guiño



Code:
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();

        //iterate over all contacts in the current frame:
        foreach (Oni.Contact contact in e.contacts)
        {
            // if this one is an actual collision:
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
                if (col != null)
                {
                    if (col.gameObject.layer == 15)
                    {
                        //if we are here we know particles are colliding with layer 15 objects.
                        //how can I know if it's the LAST PARTICLE in the rope (end of the rope) that has touched the debris?
                       
            //I know this is supposed to return the position/point of the last particle..
                        Vector4 lastPoint = solver.positions[rope.elements[rope.elements.Count - 1].particle2];

                    }

                }
            }
        }
    }
Reply


Messages In This Thread
Check for collision of last particle in rope - by docgonzzo - 23-12-2022, 01:43 AM