So i’m trying to trigger a damage event when I get to certain part of a animation to give the illusion there is some sort of skill involved when swinging a weapon but its not recognizing the function at all when trying to apply it to the animation.
Here is the script.
var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var cutter02 : Transform;
function Update ()
{
if (Input.GetButtonDown ("Fire1"))
{
cutter02.GetComponent.<Animation>().Play("Attack");
}
}
if (cutter02.GetComponent.<Animation>().isPlaying == false)
{
cutter02.GetComponent.<Animation>().CrossFade("Idle");
}
function Damage ()
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("Damage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}