I recorded an animation of my weapon attacking, and it would play when the left mouse is pressed. now the animation worked, but it kept playing by itself even i checked off “Play Automatically”.
what is happening?
i did initialized it though.
my code:
#pragma strict
var thedamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
public var TheHammer : Transform;
function Update ()
{ if (Input.GetButtonDown("Fire1"));
{
TheHammer.animation.Play("attack");
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", thedamage, SendMessageOptions.DontRequireReceiver);
}
}
}
if (TheHammer.animation.isPlaying == false)
{
TheHammer.animation.CrossFade("HammerIdle");
}
}