Model&Animation

1、FBX文件是一个完整的模型,通常内含Mesh,Material,Texture,Animation,即内含构成一个完成GameObject所需要的一切组件。可以通过以下代码来引用。

 1     //动画名称
 2     public const string ANIM_NAME0="idle";
 3     public const string ANIM_NAME1="run";
 4     public const string ANIM_NAME2="walk";
 5     public const string ANIM_NAME3="jump_pose";
 6     //模型对象
 7     private GameObject obj = null;
 8 
 9     void Start ()
10     {
11         //获取模型动画
12         obj = GameObject.Find("Constructor");
13         //设置动画播放类型为循环
14         obj.animation.wrapMode = WrapMode.Loop;
15     }
16     
17     void Update ()
18     {
19         //按键后播放不同动画
20         if (Input.GetKeyDown (KeyCode.A))
21         {
22             obj.animation.Play(ANIM_NAME0);
23         }
24         if (Input.GetKeyDown (KeyCode.B))
25         {    
26             obj.animation.Play(ANIM_NAME1);
27         }
28         if (Input.GetKeyDown (KeyCode.C))
29         {    
30             obj.animation.Play(ANIM_NAME2);
31         }
32         if (Input.GetKeyDown (KeyCode.D))
33         {    
34             obj.animation.Play(ANIM_NAME3);
35         }
36     }
View Code

相关文章:

  • 2021-12-11
  • 2021-12-27
猜你喜欢
  • 2021-06-16
  • 2021-07-16
  • 2021-11-10
  • 2021-12-12
  • 2022-01-23
  • 2021-11-24
  • 2021-12-31
相关资源
相似解决方案