2

我正在尝试在我的 Unity VR 应用程序中使用LookToWalk脚本,该脚本应该在我的 Daydream 视图上运行。在“游戏”模式下预览更改,一切都按预期工作(我将脚本配置为forward在用户摄像头朝下 30.0 度或更大时运行。但是,当我尝试构建 daydream 应用程序并将其安装在我的 Google Pixel 上CharacterController.SimpleMove时'似乎不再起作用了。日志显示 30.0 度的东西已按预期触发,但白日梦中没有看到任何动作。

你知道为什么会发生这种情况吗?它在“模拟器”而不是“真实”设备上运行似乎真的很奇怪。

using UnityEngine;
using System.Collections;

public class GVRLookWalk : MonoBehaviour {
  public Transform vrCamera;
  public float toggleAngle = 30.0f;
  public float speed = 3.0f;
  private bool shouldWalk;
  private CharacterController cc;

  // Use this for initialization
  void Start () {
    cc = GetComponent<CharacterController>();
  }

  // Update is called once per frame
  void Update () {
    if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f){
        shouldWalk = true;
    } else {
        shouldWalk = false;
    }

    if (shouldWalk) {
        Vector3 forward = vrCamera.TransformDirection (Vector3.forward);
        cc.SimpleMove (forward * speed);
  }
}
4

1 回答 1

1

相机是另一个变换的孩子吗?您不能直接移动相机。“你不能在 Unity 中直接移动相机。相反,相机必须是另一个 GameObject 的子对象,并且对位置和旋转的更改必须应用于父对象的 Transform。” https://unity3d.com/learn/tutorials/topics/virtual-reality/movement-vr

于 2016-12-12T16:20:26.570 回答