I’m drawing lines with the touch event but I need to detect the crossing of lines using line renderer this is my code:
function UpdateLine()
{
var mousePos3: Vector3 = Input.mousePosition;
//currentPen = Instantiate(thePen, thePen.transform.position,thePen.transform.rotation);
currentPen.GetComponent(LineRenderer).SetWidth(0.2f, 0.2f);
currentPen.GetComponent(LineRenderer).SetVertexCount(linePoints.Count);
for(var i = lineCount; i < linePoints.Count; i++)
{
currentPen.GetComponent(LineRenderer).SetPosition(i, linePoints[i]);
}
currentPen.GetComponent(LineRenderer).materials[0].mainTextureScale = new Vector2 (linePoints.Count-1,1);
currentPen.GetComponent(LineRenderer).name = "Swipe";
lineCount = linePoints.Count;
var hit2 : RaycastHit;
var ray2 = Camera.main.ScreenPointToRay (mousePos3);
if (!Physics.Raycast (ray2, hit2, 10000))
return;
//we've hit a sphere
if(hit2.transform.gameObject.name == "Swipe")
{
Debug.Log("Hit the line");
}
}
currentpen are my clones line renderer.
I need to hit between line renderer, I’m newbie and sorry for my English.