- Home /
Question by
ramseymona11 · Nov 22, 2013 at 12:16 AM ·
variablefirecant
Help with this melee system js code? Max distance variable not working
#pragma strict
var TheDamage : 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("Apply.Damage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
I cant get the max distance variable to work
Comment
What about it isn't working, exactly? The "if (Distance < $$anonymous$$axDistance)" line?
Try adding Debug.Logs for Distance and $$anonymous$$axDistance before the if statement to see what they are. Basic debugging should be your first step.
Your answer
