#pragma strict
var Health = 100;
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
}
#pragma strict
var Health = 100;
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
}
You can actually set the maxdistance as 3rd physics.raycast argument, instead of hit itself, so you wont need those two distance variables.
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), 1.5))
And 1.5 is a very small number, you have to be very close for it to work, try setting it to 5 or something. If that didnt work add debug message after fire1 button press and after physics and see which and which doesnt.