# Shoot projectile according to rotation

I have been trying for hours and I can’t get a projectile to shoot the way it is facing.
The projectile is only shooting directly forward. I need it to shoot up into the air.
I have its rotation set to the rotation of the camera, but how do I add force in that direction.

``````  function Fire(){
var power:int;
power=0;
while(Input.GetButton("Fire1")){
power++;
Debug.Log("Power"+power, gameObject);
yield WaitForSeconds(0.1);
}
power = power *5;

var angle = Vector3(cam.transform.eulerAngles.x,cam.transform.eulerAngles.y,cam.transform.eulerAngles.z);
// Instantiate the projectile at the position and rotation of this transform
var clone : Rigidbody;
//X,Y,Z
var positionn = Vector3(transform.position.x, transform.position.y+1, transform.position.z);

clone = Instantiate(projectile, positionn, transform.rotation);

//rotate
clone.transform.eulerAngles= angle;
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.velocity = transform.TransformDirection (Vector3.forward * power);

}
``````

Try this. When you’re setting the clone’s velocity (the very last line), use:

``````clone.velocity = (transform.rotation * Vector3.forward) * power
``````

transform.rotation will give you a quaternion, and multiplying it by Vector3.forward will give you it’s normalized ‘forward’ component in Vector3 form (or at least that’s my vague understanding of quaternion…)