ViveSoftware / ViveInputUtility-Unity

A toolkit that helps developing/prototyping VR apps.
http://u3d.as/uF7
Other
357 stars 81 forks source link

Moving the Camera Rig changes the teleport start and end offsets #22

Closed wirelessdreamer closed 6 years ago

wirelessdreamer commented 6 years ago

attach this script to a vive controller in the teleport demo, move your character around with it, and try to teleport. The origin is not where it should be once the camera rig gets moved.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HTC.UnityPlugin.Vive;

public class ViveControllerMovement : MonoBehaviour
{
    public ViveRoleProperty viveRole;
    public GameObject CameraRig;
    public ViveRoleProperty controllerDirection;

    void Update()
    {
        if (ViveInput.GetAxis(viveRole, ControllerAxis.PadY) > 0.5f)
        {
            Vector3 movementVector = Vector3.ProjectOnPlane(VivePose.GetPose(controllerDirection).up, Vector3.up);
            CameraRig.transform.position -= movementVector / 3;
        }

        if (ViveInput.GetAxis(viveRole, ControllerAxis.PadY) < -0.5f)
        {
            Vector3 movementVector = Vector3.ProjectOnPlane(VivePose.GetPose(controllerDirection).up, Vector3.up);
            CameraRig.transform.position += movementVector / 3;
        }

        if (ViveInput.GetAxis(viveRole, ControllerAxis.PadX) > 0.5f)
        {
            Vector3 movementVector = Vector3.ProjectOnPlane(VivePose.GetPose(controllerDirection).right, Vector3.up);
            CameraRig.transform.position += movementVector / 4;
        }

        if (ViveInput.GetAxis(viveRole, ControllerAxis.PadX) < -0.5f)
        {
            Vector3 movementVector = Vector3.ProjectOnPlane(VivePose.GetPose(controllerDirection).right, Vector3.up);
            CameraRig.transform.position -= movementVector / 4;
        }
    }
}
lawwong commented 6 years ago

You should move the "VROrigin" instead of "ViveCameraRig".

wirelessdreamer commented 6 years ago

Thanks, I'll give it a go

wirelessdreamer commented 6 years ago

This was the issue. Thanks.