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;
我用它来移动我的角色,但它不起作用,有人帮忙!提前谢谢!