I want to cast a ray(8 actually) from my airplanes gun(s). The problem is my script is designed to shoot the ray from the center of the camera. I need a way to project the ray forward from my gun(s).
#pragma strict
var Effect : Transform;
var TheDammage = 100;
function Update () {
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
if(Input.GetMouseButtonDown(0)){
if(Physics.Raycast (ray, hit, 100))
{
var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
Destroy (particleClone, 3);
hit.transform.SendMessage("ApplyDamage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}