How do I use raycast to simulate gun fire?

Currently, I have a 3d model of a gun that I imported from blender (150 polygons) and I want to use raycast to simulate firing.

I have no experience with raycasts so any help is welcome.

If possible I would like to know how to make raycasts do damage to my sombies (they have a collider head BTW)

try this

put this code on your gun this will fire along the Z axis, blue arrow in the editor from the guns transform position

var damageDone:float = 1;

function FireGun(){

var hit:RaycastHit;
var fwd = transform.TransformDirection (Vector3.forward);
  if (Physics.Raycast (transform.position, fwd, hit , Mathf.Infinity)) {


Put this on your zombies (the game object with the collider)

function BeenShot(Damage:float){
//code for been shot

edit: added SendMessageOptions.DontRequireReceiver to send message so you dont get an error when you shoot objects other than the targets head