Cannonball not rotating with cannon

Hi,

I made a ship with a cannon. I put an empty object on the cannon to shoot, it works but the cannonBalls wont rotate with my ship

using UnityEngine;
using System.Collections;

public class PlayerShoot : MonoBehaviour {

    public Transform firePoint;
    public GameObject CannonBall;
    public float fireRate = 0;
    public float Damage = 10;

  //  var bullet = Instantiate(bulletPrephab, GameObject.Find("Spawn Point").transform.position, transform.rotation);

    public LayerMask notToHit;

    float timeToFire = 0;

    // Use this for initialization
    void Start ()
    {
	
	}
	
	// Update is called once per frame
	void Update ()
    {
        if (fireRate == 0)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                shoot();
            }
        }
        else
        {
            if (Input.GetKey(KeyCode.Space) && Time.time > timeToFire)
            {
                timeToFire = Time.time + 1 / fireRate;
                shoot();
            }
        }
        
    }

    void shoot()

    {
        if(GameObject.Find("firePoint"))
        {
            Debug.Log("found it");
        }
        else
        {
            Debug.Log("its not here");
        }
       Instantiate(CannonBall, GameObject.Find("firePoint").transform.position, GameObject.Find("firePoint").transform.rotation);
    }
}

Ah, you are using worldspace and not local space I think.
Try doing this. change your instantiate to this and tell me what happens

Instantiate(CannonBall, GameObject.Find("firePoint").transform.position, GameObject.Find("firePoint").transform.localRotation);

They are still only going horizontally :frowning:

I FOUND IT :smiley: thnx for all the help

I changed my scripts to this:

using UnityEngine;
using System.Collections;

public class Player1CannonBall : MonoBehaviour {


    public float maxSpeed = 8f;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        Vector3 pos = transform.position;
        Vector3 velocity = new Vector3(0, maxSpeed * Time.deltaTime, 0);
        pos += transform.rotation * velocity;

        transform.position = pos;
    }
}


using UnityEngine;
using System.Collections;

public class Player1Shoot : MonoBehaviour {

    public GameObject CannonBall;
    public float fireRate = 0;
    public float Damage = 10;


    float timeToFire = 0;

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (fireRate == 0)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                shoot();
            }
        }
        else
        {
            if (Input.GetKey(KeyCode.Space) && Time.time > timeToFire)
            {
                timeToFire = Time.time + 1 / fireRate;
                shoot();
            }
        }

    }

    void shoot()

    {
        Instantiate(CannonBall, GameObject.Find("player1FirePointRight").transform.position, GameObject.Find("player1FirePointRight").transform.rotation);
        Instantiate(CannonBall, GameObject.Find("player1FirePointLeft").transform.position, GameObject.Find("player1FirePointLeft").transform.rotation);
    }
}