In a loop I call this function:
void fire(){
Bullet = Instantiate(prefab,startingPosition,transform.rotation) as GameObject;
Bullet.rigidbody.AddForce(Vector3.Normalize(startingPosition - transform.position) * force * 100);
Bullet.AddComponent<Destruction>();}
Then I have a script (Destruction.cs):
void OnCollisionEnter(Collision col){
Destroy(this);}
The fire() function is on one set of objects and I want the Destruction.cs to be on the instantiated Bullet(prefab) objects.
My problem is that the instantiated object remains without the script even though the original prefab has the script on it! And this is the reason why I am trying to add the destruction script through AddComponent…beacuse the instantiated object does not have the script that the prefab has!