如何使用Oculus Locomotion Controller传送到自定义点?

时间:2019-07-16 16:29:49

标签: unity3d oculus

按下按钮时,我试图将玩家传送到塔顶上。在Unity中,它工作正常,但是在Oculus Quest上,播放器仅处于正确位置一帧,然后向下移动。

有时候(我无法重现)播放器实际上可以正确传送。 使用“ Oculus Integration”中包含的“ Teleport Aim Handler Parabolic”进行常规传送可以正常工作。

我试图简单地移动PlayerController。 我尝试在传送前按脚本将目标标记移动到目标。 我试图通过LocomotionTeleport.DoTeleport()移动播放器,然后提高播放器位置。

我尝试过的所有方法都在编辑器中工作,但在Quest上,播放器仅在y改变之前(通常与传送前的状态相同)处于一帧的正确位置。

3 个答案:

答案 0 :(得分:0)

我找到了一种方法。 该问题来自“ OVRPlayerController ”。将其停用半秒钟,然后再传送到塔顶传送设备的顶部。 我相信有更好的方法可以做到这一点,但它可以作为一个开始。

答案 1 :(得分:0)

我和你的情况一样。正如您在回答中所说,它可以工作。但是,当HMD从其起始位置移动时(人员戴着耳机时会稍稍走动,这又会将OVRPlayerController以及摄像机装备移到3D空间中),然后将其传送到顶层时,没有传送到确切位置。它将OVRPlayerController的当前位置添加到传送位置。有时它掉在地上,玩家摔倒了。

我的等级是

Parent - >Player
 Child -> OVRPlayerController
 Child of child - > CameraRig

我的脚本如下所示,

 void Update(){
     oVRPlayerController.GetComponent<CharacterController>().enabled = isPlayerActive;
    if (recenter)
    {

         oVRPlayerController.localPosition = new Vector3(0, oVRPlayerController.localPosition.y, 0);
        cameraRig.localPosition = new Vector3(0, cameraRig.localPosition.y, 0);
        recenter = false;            
    }
}

 public void HomeTeleport() //Assign this in the menu button.
{
    isPlayerActive = false;
    Invoke("TeleToTop", 0.5f);
}


 public void TeleToTop()
{
    player.position = TopPosition;
    player.rotation = TopRotation;
    isPlayerActive = true;
    recenter = true;
}

我怀疑父玩家清空此偏移问题的游戏对象。您是否已将OVRPlayerControllers的位置直接更改为传送点?

答案 2 :(得分:0)

找到了更简单的解决方案,只需在更新位置时禁用OVRPlayerController,无需做任何延迟:

public class MoveObjectBySpace : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            var player = GetComponentInChildren<OVRPlayerController>();
            player.enabled = false;
            transform.position = new Vector3(Random.Range(-5, 5), transform.position.y, Random.Range(-5, 5));
            player.enabled = true;
        }
    }
}