Hi I am new to coding trying to use a script to play an animation for an attack and I get the following error
BCE0020: An instance of type ‘UnityEngine.Animation’ is required to access non static member ‘Play’.
#pragma strict
var Damage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var Hammer : Transform;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
GetComponent<UnityEngine.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", Damage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
Help plz