构建项目后无法旋转摄像头和头部Unity 3D

时间:2017-09-08 07:28:01

标签: c# android unity3d unityscript virtual-reality

在Unity中,我可以正确地玩这个项目, ALT +鼠标=向左,向右,向上和向下看, CTRL =倾斜头部和行走。 但是当我将这个项目构建到APK或PC(Windows)时, 头部不能向左或向右旋转

这是我自动漫步的源代码,

公共类VRAutoWalk

// Update is called once per frame
void Update () {
    // player is allowed to move
    // using Google VR button or Touchpad in Gear VR
    if (Input.GetButtonDown("Fire1")) {
        moveForward = !moveForward;
        if (moveForward == false) {
            myCC.SimpleMove(Vector3.zero);
        }
    }

    // if ALT button is pressed, rotate head
    if (Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.LeftAlt))
    {

        // Get mouse X input
        mouseX += Input.GetAxis("Mouse X") * 5;
        // Keep mouseX value between 0 and 360
        if (mouseX <= -180) { mouseX += 360; }
        else if (mouseX > 180) { mouseX -= 360; }
        // Get mouse Y input
        mouseY += Input.GetAxis("Mouse Y") * 2.4f;
        // Keep mouseY value between 0 and 360
        if (mouseY <= -180) { mouseY += 360; }
        else if (mouseY > 180) { mouseY -= 360; }
    }

    // Check to see if I should move
    if (moveForward) {
        // Find the forward direction
        Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
        // tell myCC to move forward
        myCC.SimpleMove(forward * speed);
    }
}

1 个答案:

答案 0 :(得分:1)

在构建

之前,您需要在播放器设置中检查虚拟现实支持的刻度