Here is a simple script that does what you describe:
Cannon.js
var cannonball : Transform;
function Update() {
if(Input.GetButtonUp("Fire1")) {
var projectile = Instantiate(cannonball,
transform.position,
transform.rotation);
projectile.rigidbody.AddForce(transform.right * 10000);//cannon's x axis
Physics.IgnoreCollision(projectile.collider, collider);
}
}
The Physics.IgnoreCollisions is there to prevent unwanted collisions between the projectile and the cannon. In stead of Physics.IgnoreCollisions, you could have no collider on the cannon or you could have a mesh collider on the cannon whose shape you know will not inadvertently collide with the projectiles or you could simply instantiate the projectile away from the cannon slightly.