强子 发表于 2013-3-5 08:34

Unity3D控制3d max 人物模型动作全过程 图文教程

在3d max 2010中导入绑定骨骼的人物模型,并在混合器中为其添加动作。
注意:采用“原地模式”。   
导出fbx时,注意勾选。


导入到Unity3d时,会生成fbm的文件夹(附带贴图)。
设置其动作,once还是loop一定要注意。
设置完成后,直接写js脚本就OK了。
脚本如下:var gameobj:GameObject;
function Update () {
      gameobj=GameObject.Find("laotaitai");
      if(Input.GetKey(KeyCode.W))
      {
                gameobj.transform.Translate(Vector3.forward*Time.deltaTime*2);
                animation.Play("run");
      }
else      if(Input.GetKey(KeyCode.S))
      {
                gameobj.transform.Translate(Vector3.forward*Time.deltaTime*-2);
                animation.Play("run");
      }
      else if(Input.GetKey(KeyCode.A))
      {
                gameobj.transform.Rotate(Vector3.up*Time.deltaTime*-60);
                animation.Play("run");
      }
      else if(Input.GetKey(KeyCode.D))
      {
                gameobj.transform.Rotate(Vector3.up*Time.deltaTime*60);
                animation.Play("run");
      }
      //there is no animation,please playing "idle"
      if(!animation.isPlaying)
      {
                animation.Play("idle");
      }
      // key "downArrow"
      if(Input.GetKey(KeyCode.DownArrow))
      {
                //animation.CrossFade("fight");
                animation.Play("fight",PlayMode.StopSameLayer);
      }
}最后在场景中放置cube,模型上添加 http://qq983985955-002-site1.site4future.com/unity/attachments/month_1107/110721143443e2eeaa4b457859.jpg

实现下面效果:


注意:全用animation.Play();显得很不连贯;用animation.CrossFade() 按下“w”时,会一直跑步。。。不得其解。
如果您有更好的方法,请踊跃发贴。期待您的回复。

v75273278 发表于 2013-4-25 13:43


不错 不错 不错{:soso__3922851084632044791_6:}

HLH 发表于 2013-5-7 17:36

正需要!谢谢分享

1092427682 发表于 2016-10-26 18:49


不错 不错 不错

xu友友 发表于 2016-10-27 09:17

恩恩学习了

转角 发表于 2017-2-14 09:03

真心顶

gaojinjin 发表于 2017-2-14 09:18

难得一见的好帖

wai2dance 发表于 2017-2-14 08:56

很好哦

chiuan 发表于 2017-2-14 09:19

不错不错

gaojinjin 发表于 2017-2-14 08:26

LZ真是人才
页: [1]
查看完整版本: Unity3D控制3d max 人物模型动作全过程 图文教程