Rotation Projectile Script Difficulties

Hi

I created a cylinder game object to sample as an arrow. When I run the script the projectile instantiates vertically (which seems to be a common problem for some), instead of firing straight.

This script is attached straight on my character (which currently is just a capsule) and is called by pressing a touchscreen firebutton. The arrow prefab currently has no other scripts attached to it. I’ve also attempted to adjust the prefab in the proper direction to no avail.

My efforts are in the following code:

var projectile : Rigidbody;
var speed = 20;
var fireitem : GameObject;
var target : Transform;
var ammoCount = 20;
var reloadTime = 0.5;

private var lastShot = -10.0;

function fire () {
	if (Time.time > reloadTime + lastShot && ammoCount > 0) {

		var misslelocation = fireitem.transform.position;
		var misslerotation = transform.rotation;

	//	var misslerotation = Quaternion.FromToRotation(Vector3.up, -transform.forward);    
	//	var misslerotation = Quaternion.Euler(90, 0, 0);
   	//	var launchbullet : Rigidbody = Instantiate (projectile, misslelocation,  gameObject.transform.rotation );
   	//	var launchbullet : Rigidbody = Instantiate (projectile, misslelocation,  transform.rotation );

    	var launchbullet : Rigidbody = Instantiate (projectile, misslelocation, misslerotation);

		launchbullet.transform.LookAt(target);
   		launchbullet.rigidbody.AddForce ( launchbullet.transform.forward * speed);
      
		Physics.IgnoreCollision( launchbullet. collider, transform.root.collider );    
		lastShot = Time.time;
   		ammoCount--;
   	}

}	

In the code, I’ve left in some different approaches that I’ve tried from other users issues with projectile rotation within this site.

Could anyone assist me or point me in the right direction of why my projectile will not fire properly?

Thanks

When theory fails, you have TRIAL & ERROR, try this before launching and pause, i dont understand where is the LAUNCH origin so this is rough but it works on my ship:

     var ShootDirection = launchbullet.transform.forward; // To try the SHOOT DIRECTION
     
    Debug.DrawRay (misslelocation.transform.position,   misslelocation.transform.worldToLocalMatrix.MultiplyVector(ShootDirection) * 30, Color.green);
Debug.Break();