Bullet always facing the sky.

Ok people, once again i’m here bagging on my knees for your help. So here’s the deal. I have this Tank that is supposed to shoot missiles and here’s what i have.

@script ExecuteInEditMode()

var bulletPrefab: Transform ;
var tirosDisparados: int =0;
var bulletSpeed: float = 60;
var buttonX: int = 0;
var buttonY: int = 0;

function Update()
{
 if (Input.GetButtonDown("Fire1"))
 {
 var shoot = Instantiate(bulletPrefab,GameObject.Find("Spawn").transform.position,Quaternion.identity);
 shoot.rigidbody.AddForce(GameObject.Find("Spawn").transform.forward * bulletSpeed);
//Bullet Counting
 tirosDisparados = tirosDisparados + 1;
 Debug.Log(tirosDisparados);

 
 }
}

The problem is, no matter the rotation of the prefab, my missile always faces to the sky, I believe it’s something related to the quaternion, but since, i don’t know how to work with it (i’m a noob), i’m asking for your help… Hope you can help me.
Thanks once again to this wounderfull community.

Quaternion.identity is short for no rotation.

Try this one:

var spawn:GameObject;

//This is creating a reference to the spawn object for faster access.
function Start(){
   spawn =GameObject.Find("Spawn");}

var shoot =Instantiate(bulletPrefab,spawn.transform.position, spawn.transform.rotation);
 shoot.rigidbody.AddForce(spawn.transform.forward * bulletSpeed);

You are using Quaternion.identity (zero)

 if (Input.GetButtonDown("Fire1"))
 {
     var spawn = GameObject.Find('Spawn');
     var shoot = Instantiate(bulletPrefab, spawn.transform.position, spawn.transform.rotation);
     shoot.rigidbody.AddForce(spawn .transform.forward * bulletSpeed);
    //Bullet Counting  
    tirosDisparados = tirosDisparados + 1;
    Debug.Log(tirosDisparados);   
 }

Another thing, you really shouldent Find the gameobjects like that. Its best you cache the spawn object on awake.

For fafase and nventimiglia :

Using the spawn rotation fixes it… Or not, well, if i rotate the spawn now, x axis makes my missile being shoot upwards or downwards, the y one, makes it shoot more to the left or to the right, and only z makes the bullet rotate, in this case the wrong direction, since now instead of being always facing up, is always facing left, as i set the spawn z rotation to 90…