med-material / Whack_A_Mole_VR

Whack-A-Mole in VR
MIT License
3 stars 15 forks source link

Test and Implement VR Recentering ("Teleporting") #162

Closed bastianilso closed 1 year ago

bastianilso commented 2 years ago

Often when people enter VR, they are not perfectly centered at world position 0.0, 0.0, 0.0. This leads to a number of issues:

According to Hamzah and Steffen, it should be possible to re-center VR through the XR Framework's API (see code below). This way, we can transport people back to 0.0, 0.0, 0.0 regardless of where they are. I can see several ways we can do this:

1) When a Whack-A-Mole game starts (after countdown), automatically recenter and calibrate the current position to be 0.0, 0.0, 0.0 . This design is simple and should be quick to implement. (e0003a39e86dfaca61b60d03627186a4399e833a)

2) If we eventually move to an interaction paradigm where no therapist is facilitating, we could have a preliminary calibration stage , we could consider showing a preliminary calibration screen, which requests the player to sit down and get ready to play. The player confirms by pressing any button on the VR controller or on the keyboard. Alternatively, we wait for participant movements to become stable (indicating that they sit still). image

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;

public class Constraint : MonoBehaviour
{
    public Camera Cam;
    public bool constrain;
    // Start is called before the first frame update

    // Update is called once per frame
    void Update()
    {
        if (constrain == true)
        {
            InputTracking.Recenter();
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            constrain = false;
        }
    }
}