I am trying to make a basic melee weapon swing when I left click. I wrote a short script to try and get it working:
if (Input.GetButtonDown("Fire1"))
{
//Attack animation
TheSystem.animation.Play("melee_attack");
Debug.Log("Clicked");
But I get this error:
The animation state melee_attack could not be played because it couldn't be found!
Please attach an animation clip with the name 'melee_attack' or call this function only for existing animations.
UnityEngine.Animation:Play(String)
MeleeSystem:Update() (at Assets/Script/MeleeSystem.js:15)
In the attached object I had just the Animator component which would just play and loop automatically so I unticked that and added an animation component, selected the anim from my assets and unticked Play Automatically.
Any help would be appreciated!
↧