我想根据操纵杆的输入来移动游戏对象,而将手机固定在横向模式下。
以下是我的代码,
selectedGameObject.transform.forward = new Vector3(joyStick.Horizontal, 0f, joyStick.Vertical);
if(joyStick.Direction.y > 0)
{
selectedGameObject.transform.Translate(new Vector3(joyStick.Horizontal * 0.01f, 0.0f, joyStick.Vertical * 0.01f));
}
if (joyStick.Direction.y < 0)
{
selectedGameObject.transform.Translate(new Vector3(joyStick.Horizontal * 0.01f, 0.0f, -joyStick.Vertical * 0.01f));
}
不幸的是,游戏对象奇怪地移动,有时以相反的方式移动。我想念什么?