- 最后登录
- 2017-5-15
- 注册时间
- 2012-3-1
- 阅读权限
- 90
- 积分
- 32973
- 纳金币
- 32806
- 精华
- 12
|
脚本如下:
var gameobj:GameObject;
function Update () {
gameobj=GameObject.Find("laotaitai");
if(Input.GetKey(KeyCode.W))
{
gameobj.transform.Translate(Vector3.forward*Time.deltaTime*2);
animation.Play("***n");
}
else if(Input.GetKey(KeyCode.S))
{
gameobj.transform.Translate(Vector3.forward*Time.deltaTime*-2);
animation.Play("***n");
}
else if(Input.GetKey(KeyCode.A))
{
gameobj.transform.Rotate(Vector3.up*Time.deltaTime*-60);
animation.Play("***n");
}
else if(Input.GetKey(KeyCode.D))
{
gameobj.transform.Rotate(Vector3.up*Time.deltaTime*60);
animation.Play("***n");
}
//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);
}
}
|
|