【发布时间】:2014-10-26 13:44:33
【问题描述】:
我使用 Unity 开发了一款 2D 游戏。我使用了 EasyTouch 包。当使用左右键时,通过设置左侧的flag = 3和右侧的flag = 4来触发动画。但是,如果我改用操纵杆,左侧和右侧的动画都不起作用。有人可以帮我解决这个问题吗?非常感谢。
void Movement()
{
if(joystick.JoystickAxis.x<0)
{
//if (Input.GetAxisRaw("Horizontal")<0) {
anim.SetInteger("flag",3);
transform.Translate(Vector3.left*speed*Time.deltaTime);
}
if(joystick.JoystickAxis.x>0)
{
//if(Input.GetAxisRaw("Horizontal")>0) {
anim.SetInteger("flag",4);
transform.Translate (Vector3.right*speed*Time.deltaTime);
}
if(joystick.JoystickAxis.y<0)
{
anim.SetInteger("flag",1);
//if (Input.GetAxisRaw("Vertical")<0) {
transform.Translate (Vector3.down*speed*Time.deltaTime);
}
if(joystick.JoystickAxis.y>0)
{
anim.SetInteger("flag",2);
//if (Input.GetAxisRaw("Vertical")>0) {
transform.Translate (Vector3.up*speed*Time.deltaTime);
}
}
【问题讨论】:
标签: unity3d unityscript