//Are two lines intersecting? private void LineLine() { MyVector2 l1_p1 = t1_p1_trans.position.ToMyVector2(); MyVector2 l1_p2 = t1_p2_trans.position.ToMyVector2(); MyVector2 l2_p1 = t2_p1_trans.position.ToMyVector2(); MyVector2 l2_p2 = t2_p2_trans.position.ToMyVector2(); bool isIntersecting = Intersections.LineLine(l1_p1, l1_p2, l2_p1, l2_p2, shouldIncludeEndPoints: true); //Display //Gizmos.DrawLine(l1_p1.ToVector3(), l1_p2.ToVector3()); //Gizmos.DrawLine(l2_p1.ToVector3(), l2_p2.ToVector3()); //if (isIntersecting) //{ // MyVector2 intersectionPoint = Intersections.GetLineLineIntersectionPoint(l1_p1, l1_p2, l2_p1, l2_p2); // //Gizmos.color = Color.red; // //Gizmos.DrawSphere(intersectionPoint.ToVector3(), 1f); //} //With mesh //Line TestAlgorithmsHelpMethods.DisplayLineMesh(l1_p1, l1_p2, 0.5f, Color.white); TestAlgorithmsHelpMethods.DisplayLineMesh(l2_p1, l2_p2, 0.5f, Color.white); //If they are intersecting we can also get the intersection point if (isIntersecting) { MyVector2 intersectionPoint = Intersections.GetLineLineIntersectionPoint(l1_p1, l1_p2, l2_p1, l2_p2); TestAlgorithmsHelpMethods.DisplayCircleMesh(intersectionPoint, 1f, 20, Color.red); } }