Change bullet direction with player direction

I have been reading for ages about this and each question I find suggests what I aready have but not sure why my code is not working.

using UnityEngine;
using System.Collections;

public class shoot : MonoBehaviour {

	public GameObject bullet;

	//Forces to apply to our projectile 
	public float projectileForwardForce; 
	public float projectileUpForce; 
	


	// Update is called once per frame
	void Update () {

		//If our left mouse button is clicked 
		if (Input.GetMouseButtonDown(0)) 
		{ 
			Vector3 offsetForward = transform.forward * 2; 
			Vector3 offsetUp = transform.up; 
			
			//Calculate our offset position 
			Vector3 finalPosition = transform.position + offsetForward + offsetUp; 

			//Creates a new object at our current position and rotation 
			GameObject myObject = Instantiate(bullet, finalPosition,bullet.transform.rotation) as GameObject; 

			//Apply a force to our tank shell to make it fly into the distance 
			myObject.rigidbody.AddRelativeForce(myObject.transform.forward * projectileForwardForce, ForceMode.Impulse); 

			//Add a small force upwards to make it fly into the arc a little 
			myObject.rigidbody.AddRelativeForce(myObject.transform.up * projectileUpForce, ForceMode.Impulse); 
			Destroy(bullet,2.0f);

		} 
	}
}

You have some problems here. First, you are setting the bullet’s rotation to the rotation of the prefab, not the rotation of the player. Assuming this script is on the player, you need to change line 27:

     GameObject myObject = Instantiate(bullet, finalPosition, transform.rotation) as GameObject; 

Your other problem is that you are using world vectors to apply force in the local coordinate system. Try this instead:

     Vector3 vForce = transform.forward * projectileForwardForce + transform.up * projectileUpForce;
     myObject.rigidbody.AddForce(vForce, ForceMode.Impulse); 

Since the rotation of the player object and the rotation of the projectile match, we an use the player’s ‘forward’ and ‘up’.