有个问题一直很头疼。在3Dmax中调好了一辆车的模型动画,导入到unity中之后,编写脚本
using UnityEngine;
using System.Collections;
public class ggg : MonoBehaviour {
public const string Lun="nn";
private GameObject obj;
// Use this for initialization
void Start () {
obj=GameObject.Find ("car");
obj.animation.wrapMode=WrapMode.Loop;
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown (KeyCode.A)){
obj.animation.Play (Lun);
}
}
}
运行之后发现汽车没动,并且有错误
MissingComponentException: There is no 'Animation' attached to the "car" game object, but a script is trying to access it.
You probably need to add a Animation to the game object "car". Or your script needs to check if the component is attached before using it.
。。请教大家,这究竟该怎么办?