Hi, I'm trying to get a collider from this line render ( if (Input.GetMouseButton(0)) { lineX.positionCount = i + 1; Vector3 mPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 100); lineX.SetPosition(i, Camera.main.ScreenToWorldPoint(mPosition)); i++; /* Add Collider */ BoxCollider bc = lineGO.AddComponent<BoxCollider>(); bc.transform.position = lineX.transform.position; bc.size = new Vector3(0.1f, 0.1f, 0.1f); } else { lineX.positionCount = 0; i = 0; BoxCollider[] lineColliders = lineGO.GetComponents<BoxCollider>(); foreach (BoxCollider b in lineColliders) { Destroy(b); } } ) to hit 2d sprites with 3D Colliders (varying 3D colliders) on the Z axis, is there anyway of working around this as I can't use 2D colliders as i want the sprite game objects to be moving towards the camera. void OnCollisionEnter(Collision other) { if (other.gameObject.name == "Line") { Camera.main.GetComponent<AudioSource>().Play(); Destroy(gameObject); scoreReference.text = (int.Parse(scoreReference.text) + 1).ToString(); } } Above is the collision code. Please help!
public class LineRender : MonoBehaviour { public Color c1 = Color.black; public Color c2 = Color.red; private GameObject lineGO; private LineRenderer lineX; private int i = 0; // Use this for initialization void Start () { lineGO = new GameObject("Line"); lineGO.AddComponent<LineRenderer>(); lineX = lineGO.GetComponent<LineRenderer>(); lineX.material = new Material(Shader.Find("Mobile/Particles/Additive")); lineX.startColor = c1; lineX.endColor = c2; lineX.startWidth = 0.3F; lineX.endWidth = 0; lineX.positionCount = 0 ; } } Should have put this in with the original but here is the void start for the line render.