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”时,会一直跑步。。。不得其解。
如果您有更好的方法,请踊跃发贴。期待您的回复。
不错 不错 不错{:soso__3922851084632044791_6:} 正需要!谢谢分享
不错 不错 不错 恩恩学习了 真心顶 难得一见的好帖 很好哦 不错不错 LZ真是人才
页:
[1]