Ray Cast not casting.

I’m trying to send a short distance raycast in order to activate in-game, things such as doors and buttons. I’ve been trying to get this to work for a couple days but I’ve found no luck. I can’t seem to find anything wrong with my script. I’ve done much debugging and have found out that the raycast is simply not initiating. Look over my script and tell me what is going on.

#pragma strict

var RaycastDist : float = 5;
var action = 1;

function Update() {
	var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width / 2, Screen.height / 2, 0));
	var hit : RaycastHit; 
	var fwd = transform.TransformDirection (Vector3.forward);
	if(Input.GetKeyDown(KeyCode.E)) {
		if(Physics.Raycast (ray, hit)){
			hit.collider.SendMessage("Action", action, SendMessageOptions.DontRequireReceiver);
		}
	}
}

Give yourself some help with a scene view line draw that represents the raycast. You will need to show the scene view tab along with your game view tab to get a good idea of the cast.

#pragma strict
 
var RaycastDist : float = 5;
var action = 1;
 
function Update() {
    var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width / 2, Screen.height / 2, 0));
	Debug.DrawRay (ray.origin, ray.direction * 10, Color.yellow);
    var hit : RaycastHit; 
    var fwd = transform.TransformDirection (Vector3.forward);
    if(Input.GetKeyDown(KeyCode.E)) {
        if(Physics.Raycast (ray, hit)){
            hit.collider.SendMessage("Action", action, SendMessageOptions.DontRequireReceiver);
        }
    }
}