i have instatiated a transform var, which is connected to a prefab. when i try and destroy it, it comes up with an error, "can't remove transform as mesh render, box collider and rigidbody relies on it."
heres the code. i don't understand, i should be sound.
var bullet_Prefab : Transform; var speed = 5;
function Update () {
if(Input.GetButtonDown("Fire1")) { var bullet = Instantiate(bullet_Prefab, transform.position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * speed);
Destroy(bullet, 5);
}
}
Thank You @jtbentley. THAT solved my problem. Seeing as the Unity docs themselves prefer instantiating a transform above instantiating a GameObject. http://docs.unity3d.com/Manual/InstantiatingPrefabs.html
– gregroberts