Hello everyone I have yet another problem with raycasting. here is my script
var dis : int = 5;
var hit : RaycastHit;
function Update () {
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
var ray = Camera.main.ScreenPointToRay (touch.position);
if (Physics.Raycast (ray, hit, dis))
{
if (hit.collider.gameObject.tag == "Cubie2"){
Debug.Log("You find a CUBIE!");
Destroy(GameObject.FindWithTag("Cubie2"));
if (Physics.Raycast (ray, hit, dis))
{
if (hit.collider.gameObject.tag == "Cubie")
{
Debug.Log("You find a CUBIE2!");
Destroy(GameObject.FindWithTag("Cubie"));
if (Physics.Raycast (ray, hit, dis))
{
if (hit.collider.gameObject.tag == "Cubie3")
{
Debug.Log("You find a CUBIE3!");
Destroy(GameObject.FindWithTag("Cubie3"));
if (Physics.Raycast (ray, hit, dis))
{
if (hit.collider.gameObject.tag == "Cubie4")
{
Debug.Log("You find a CUBIE4!");
Destroy(GameObject.FindWithTag("Cubie4"));
if (Physics.Raycast (ray, hit, dis))
{
if (hit.collider.gameObject.tag == "Cubie5")
{
Debug.Log("You find a CUBIE5!");
Destroy(GameObject.FindWithTag("Cubie5"));
}
}
}
}
}
}
}
}
}
}
}
}
}
My problem is this only works for 1 tag, Can some one please help me and sorry for the format I tried my best to get in it here as close to how it should be.
Blockquote