I am using this code:
var projectile : GameObject;
var speed = 50;
var fireRate = 0.11;
private var lastShot = -10.0;
function Update ()
{
if(Input.GetButtonDown("Fire1")){
if(Time.time > fireRate+lastShot){
clone = gameObject;
Instantiate(projectile, transform.position, transform.rotation);
projectile.tag = "Bullet";
clone.gameObject.AddForce(transform.forward * speed);
lastShot = Time.time;
}
Destroy(clone.Bullet, 3);
}
}
And when I try to fire a bullet in the game, it says:
“UnassignedReferenceException: The variable projectile of ‘gunfire’ has not been assigned.”
What am I doing wrong?