- Home /
 
Cannot touch cloned prefabs
I want to make a touch destroy game, so every time i destroy a random spawned object the score rises I have 1 object prefab, it has BoxCollider(for raycasting) and 2 Scripts (TouchDestroy and AutoDestroy)
Unfortunately when i test it on Android Device, the touch input has no effect at all.
this is my TouchDestroy script
 #pragma strict
 var ray : Ray;
 var hit : RaycastHit;
 if(Input.GetMouseButtonDown(0))
         {
             Debug.Log("left click");
             ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             if(Physics.Raycast(ray,hit))
             {
                 if(hit.transform.tag =="Player")
                 {
                     Score.score+=100;
                     Destroy(hit.collider.gameObject);
                 }
             }
         }
 
               i have tried this alternative touch destroy but still did not work
 if (Input.touchCount > 0) 
     {
         Debug.Log("touched");
         var dtouch : Touch = Input.GetTouch(0);
         ray = Camera.main.ScreenPointToRay(dtouch.position);
         if(Physics.Raycast(ray,hit))
             {
                 Debug.Log("Raycasted");
                 if(Input.touchCount == 1)
                 {    
                     Debug.Log("one touch");
                     if(dtouch.phase == TouchPhase.Began)
                        {
                          Score.score+=100;
                         Destroy(hit.collider.gameObject);
                     }
                 }
             }
     } 
 
               anybody can help me solve this?
I have the same problem with destroying cloned prefabs. If you solved it, please tell me how. Here's my question: http://answers.unity3d.com/questions/638075/how-to-destroy-object-by-touch.html
Your answer
 
             Follow this Question
Related Questions
input touch android help 0 Answers
Destroying GameController Respawns? 0 Answers
Android - touch a 3d object and something happens to it 1 Answer
Touch Input madness 2 Answers
Touch joystick tutorials ? 0 Answers