Animation 奇怪的丢失组件异常,尽管一切正常

Animation 奇怪的丢失组件异常,尽管一切正常,animation,unity3d,unityscript,Animation,Unity3d,Unityscript,我刚开始用Unity创建我的第一个游戏,我已经结巴了。我尝试设置一个狼牙棒的动画,并在单击鼠标左键时运行动画,但我遇到了一个奇怪的错误: MissingComponentException: There is no 'Animation' attached to the "Mace" game object, but a script is trying to access it. You probably need to add a Animation to the game object "

我刚开始用Unity创建我的第一个游戏,我已经结巴了。我尝试设置一个狼牙棒的动画,并在单击鼠标左键时运行动画,但我遇到了一个奇怪的错误:

MissingComponentException: There is no 'Animation' attached to the "Mace" game object, but a script is trying to access it.
You probably need to add a Animation to the game object "Mace". Or your script needs to check if the component is attached before using it.
UnityEngine.Animation.Play (System.String animation) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/Animations.cs:569)
MeleeSystem.Update () (at Assets/MeleeSystem.js:11)
引用此脚本:

#pragma strict

var theDamage : int = 50;
var Distance : float;
var maxDistance : float = 1.5;
var TheMace : Transform;

function Update (){

if(Input.GetButtonDown("Fire1")){
    TheMace.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);
            }
    }
}
}
#pragma strict
损伤变量:int=50;
变量距离:浮动;
var maxDistance:浮点=1.5;
向量空间:变换;
函数更新(){
if(Input.GetButtonDown(“Fire1”)){
TheMace.animation.Play(“攻击”);
var-hit:RaycastHit;
if(物理.光线投射(变换.位置,变换.变换方向(矢量3.向前),命中)){
距离=命中距离;
如果(距离<最大距离){
hit.transform.SendMessage(“ApplyDamage”,theDamage,SendMessageOptions.DontRequireReceiver);
}
}
}
}
其中第11行是:
ace.animation.Play(“攻击”)

我做了所有该做的事。以下是我工作区的屏幕截图:

其中:

1) 是近战-你可以看到,狼牙棒是它的孩子。 2) 近战脚本。 3) 已正确分配ACE变量

我知道我错过了这里的一小部分,但作为一个完全的初学者,我就是看不出来。你能推我一下吗

编辑: 检查员屏幕截图:

您的对象已连接组件。它需要一个组件来代替


Animator
用于操纵Mecanim动画<代码>动画
用于播放随模型导入的旧动画剪辑。

能否显示附加到Mace对象的组件?这个错误非常清楚地定义了问题所在。@SirBraneDamuj Mace对象包含一个名为Grip的圆柱体,这就是它所包含的全部内容。我不是指它的子对象,我是问附加了哪些组件。换句话说,单击Mace并查看其inspector窗口(最右边的窗格)。你应该在最上面看到一个转换,后面是所有其他组件。@SirBraneDamuj对不起,我知道,我刚刚编辑了我的文章。嘿,我看到了发生的事情。现在它说:
动画组件“Mace”使用的AnimationClip“Attack”必须标记为遗留我在这里遗漏了什么(您必须在导入的模型上找到动画剪辑,并更改其中一个设置(我现在不知道它的名称)。这是一个下拉列表,其中一个设置是遗留设置。这可能会对您有所帮助