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();
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();
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().Play();
Destroy(gameObject);
scoreReference.text = (int.Parse(scoreReference.text) + 1).ToString();
}
}
Above is the collision code.
Please help!