Question by 
               dank_memes420 · May 22, 2016 at 10:22 AM · 
                collisionprojectileclonesflight sim  
              
 
              Collisions not working
I am trying to have my projectiles fire from my plane for my flight sim and upon hitting the terrain, explode. I got them to fire and go forward but they simply go thru the terrain. I have colliders on terrain and the missile as well as rigid bodies. I have read for hours on the forums and trawled through google but nothing happens. My other problem is that when I click my mouse, the code instantiates a clone from a clone. This makes it so i got from 1 to 3 to 5 and so on until it causes the game to lag. I want to make more objects and fire them from the original location. Thanks
 using UnityEngine;
 using System.Collections;
 
 
 public class BigMissileShooter : MonoBehaviour {
     GameObject prefab;
     public ParticleSystem exp1;
     Component prefab2;
     public float speed = 200.0f;
     public int count = 0;
     //public GameObject bigMissile1;
     // Use this for initialization
     void Start () {
         prefab = Resources.Load("BigMissile") as GameObject;
        // prefab2 = Resources.Load("bigMissileExp1") as ParticleSystem;
         
     }
     
     
     // Update is called once per frame
     void Update () {
         if(Input.GetMouseButtonDown(0))
         {
   
             
                 GameObject bigMissile = Instantiate(prefab, transform.position,transform.rotation) as GameObject;
                 bigMissile.transform.position = transform.position + Camera.main.transform.forward * 2;
                 Rigidbody rb = bigMissile.GetComponent<Rigidbody>();
             
                 rb.AddForce(transform.forward * 250, ForceMode.Impulse);
                 Destroy(bigMissile, 3.0f);
                
                 Physics.IgnoreCollision(bigMissile.GetComponent<Collider>(), GetComponent<Collider>());
             ParticleSystem a = bigMissile.GetComponent<ParticleSystem>();
             a.Play();
             
         }
         count++;
 
     }
     void OnCollisionEnter(Collision col)
     {
         if (col.gameObject.name != "Terrain")
         {
 
             speed = 0.0f;
             if (speed >= 0.0f)
             {
                 speed = 0.0f;
             }
             exp1.Play();
             
             
             if (exp1.particleCount==500)
             {
 
                 Destroy(gameObject);
             }
 
         }
     }
 }
 
 
 
              
               Comment
              
 
               
              Your answer