(17-10-2022, 11:01 AM)josemendez Wrote: Hi!Here is the code part that has importance.
Could you share the code you're using? I can't help much otherwise... probably you're not using correct particle indices or not checking which actor they belong to.
//Find and get middle contact point
//
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
_contacts = e.contacts;
for (int i = 0; i < _contacts.Count; i++)
{
var collider = world.colliderHandles[_contacts[i].bodyB].owner;
if (collider != null && (collider.gameObject.tag == "Ball" || collider.gameObject.tag == "MainBall"))
{
//Destroy(collider.gameObject);
ballPool.Despawn(collider.gameObject);
if (Health > 0)
{
Health--;
if (Health <= 0)
{
//Tear the rope apart from last position of ball contacted with rope
//Or just from center
TraverseAndCutRope();
Rope.surfaceCollisions = false;
}
if (TextMesh != null)
TextMesh.text = Health.ToString();
}
break;
}
}
}
public void TraverseAndCutRope()
{
int count = Rope.elements.Count;
if(count > 0)
{
//Odd number like 1,3,5
//Can find a center, cut from center
if(count % 2 == 1)
{
int target = count / 2;
Rope.Tear(Rope.elements[target]);
}
//Even number like 2,4,6
//Doesnt have a center, cut from center +-1
else
{
int target = count / 2;
Rope.Tear(Rope.elements[target]);
}
//Rebuild rope
Rope.RebuildConstraintsFromElements();
}
else
{
Debug.Log("No Elements");
return;
}
}