Unity 2D函数gameObject.transform.Translate(...)不起作用

时间:2015-03-09 07:28:11

标签: c# unity3d

    Vector3 localScale = transform.localScale;
    //Translation$
    if (Input.GetKey (KeyCode.LeftArrow)) 
    {
        gameObject.transform.Translate (-speed * Time.deltaTime);
        if (localScale.x > 0)
        {
            localScale.x *= -1.0f;
        }
    }

    if (Input.GetKey(KeyCode.RightArrow))
    {
        gameObject.transform.Translate (speed * Time.deltaTime);
        if (localScale.x < 0)
        {
            localScale.x *= -1.0f;
        }
    }
    transform.localScale = localScale;

我用它来移动我的角色,但它不起作用,有人帮忙!提前谢谢!

0 个答案:

没有答案