- Home /
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               aigbe15 · Jun 04, 2015 at 02:01 PM · 
                instantiateraycastvuforiaraycasthit  
              
 
              How can I instantiate an explosion using Raycasting?
I'm trying to have an explosion play when the ray collides with the model. As of now the object destroys but I have no idea how to actually make an explosion appear where that specific object was.
Here is my script:
using UnityEngine; using System.Collections;
 public class touch2 : MonoBehaviour {
     public GameObject Tower;
     public GameObject Poof;
     
     private Ray ray; // cast array
     public RaycastHit rayHitInfo = new RaycastHit(); // object that was hit by array
     // Update is called once per frame
     void Update () {
         
         if (Input.touches.Length <= 0) 
         {
             //if no touch recognised then there will be no interaction
         } 
         else 
         {
             for (int i = 0; i < Input.touchCount; i++)
             {
                 if(Input.GetTouch(i).phase == TouchPhase.Began)
                 {
                     ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position); // creates ray from screen point positoin
                     if(Physics.Raycast(ray, out rayHitInfo))
                     {
                         Destroy (rayHitInfo.transform.gameObject);
                         
                         
                     }
                     
                 
                 }
             }
         }
     }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                