I have been following this guys tutorial, and when it has come to 3:30 second in the video (3. Unity Tutorial Animation and Health - Create a Survival Game - YouTube) he left clicks and the distance # updates as he left clicks. I have the same script as him and when i left click nothing happens and nothing updates? So heres my code and thanks for anyone and everyone’s help.
#pragma strict
var dmg : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
function update()
{
if (Input.GetButtonDown ("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast(transform.position,transform.TransformDirection(Vector3.forward),hit))
{
Distance=hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("applydmg",dmg,SendMessageOptions.DontRequireReceiver);
}
}
}
}