Pirate game cannons firing in the wrong direction

At the moment I am working on a pirate game but there is a bug I cannot seem to fix. The C# script below is powering the cannons. when I fire them on everyone of them fire forward, even though I have rotated the bullet spawns to face sideways from the ship. Please tell me if it is something wrong with my code and what it is, I have a feeling that it might be the “Quaternion.Identity” is making it point in the direction the ship is rather than the ball spawns.

Thankyou for your help.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Cannons : MonoBehaviour {

public Transform[ ] cannons = new Transform[4];
public int activeCannon = 0;
public Transform cannonBall;
public Transform gunSmoke;
public float bulletSpeed = 3000.0f;
void Start () {

}

// Update is called once per frame
void Update () {
float wheel = Input.GetAxis (“Mouse ScrollWheel”);
if (wheel > 0)
{
activeCannon++;
if (activeCannon > cannons.Length-1) activeCannon = 0;
}
else if (wheel < 0)
{
activeCannon–;
if (activeCannon < 0) activeCannon = cannons.Length-1;
}

//fire
if(Input.GetButtonDown (“Fire1”))
{
Transform bullet = (Transform)Instantiate(cannonBall, cannons[activeCannon].position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * bulletSpeed);
Transform smoke = (Transform)Instantiate(gunSmoke, cannons[activeCannon].position, Quaternion.identity);
}
}
}

I think your problem might be with, transform.forward. Double check that the object the script is attached to has it’s blue z axis facing the direction you want.
If that still doesn’t work, try using transform.TransformDirection(0,0,1)
Hope this helps!

Thank you for your help, I have found the bug. Because I had the script on the ship it was using the ships forward , so I simply specified it to use the spawnpoint’s forward