IEnumerator VerletCo() { Debug.Break(); yield return(null); while (true) { for (int j = 0; j < verlet.stiffness; ++j) { for (int i = 0; i < composite.constraints.Count; i++) { IConstraint constraint = composite.constraints[i]; if (constraint is DistanceConstraint) { DistanceConstraint dc = constraint as DistanceConstraint; int i1 = composite.particles.IndexOf(dc.p1); int i2 = composite.particles.IndexOf(dc.p2); title.text = "Iteration:" + (j + 1) + "/" + verlet.stiffness + " Relax nodes: " + (i1 + 1) + " and " + (i2 + 1); links[i].GetComponent <Image>().color = Color.red; } else if (constraint is PinConstraint) { PinConstraint pc = constraint as PinConstraint; int index = composite.particles.IndexOf(pc.p); title.text = "Iteration:" + (j + 1) + "/" + verlet.stiffness + " Pin node: " + (index + 1); } else { title.text = ""; } constraint.Relax(); UpdateView(); UpdateLinks(); yield return(null); if (i < links.Count) { links[i].GetComponent <Image>().color = linkPrefab.GetComponent <Image>().color;; } } } for (int i = 0; i < verlet.composites[0].particles.Count; ++i) { title.text = "Move node: " + (i + 1); Particle p = verlet.composites[0].particles[i]; p.Move(verlet.friction, verlet.gravity); arrow.gameObject.SetActive(true); arrow.transform.position = p.pos; arrow.transform.rotation = Quaternion.LookRotation(Vector3.back, p.pos - p.lastPos); UpdateView(); UpdateLinks(); yield return(null); arrow.gameObject.SetActive(false); } } }