Looking at the related tags I've had no luck getting this instantiate code fixed.
var projectile : Rigidbody;
and at some point, the Shoot function gets called.
function Shoot()
{
var instantiatedProjectile : Rigidbody;
instantiatedProjectile = Instantiate(projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection ( Vector3( 0,0, 18));
Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);
lastShot = Time.time;
timesShot +=1;
}
According to unity, the problem is in this line:
instantiatedProjectile = Instantiate(projectile, transform.position, transform.rotation );
projectile and instantiateProjectile are both Rigidbody. There shouldn't be anything to change here. What am I missing?
Worth noting: I copy and pasted the instantiate code from another script and both the code, the prefab (projectile) and the world is nice and dandy. For some reason when I'm trying to reuse the code/prefab I'm getting this.
And the Prefab shooting the projectile also destroys itself with the shots. Even though I'm reusing the IgnoreCollision line.
This is a shot in the dark, but did you make sure to drag'n'drop the prefab onto the variable "projectile" in the editor? If not, Unity won't know which prefab to instantiate a copy of at runtime.