I am trying to write a piece of code that will play one animation if a certain weapon is equipped and another if the other weapon is equipped. I have been trying to use tags for this and my code is as follows:
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
if (GameObject.tag == "Sword")
{
// Attack animation.
animation.Play("SwordAttack");
}
else if (GameObject.tag == "Mace")
{
animation.Play("MaceAttack");
}
}
I keep getting the Error : An instance of type "UnityEngine.GameObject is required to access non static member “tag”.
Any help would be appreciated.