using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;

public class MenuAttach : MonoBehaviour {

    private void Start()
    {
        StartCoroutine(AttachToController());
    }

    private IEnumerator AttachToController()
    {
        var followScript = GetComponent<VRTK_TransformFollow>();
        if (followScript != null)
        {
            var rightController = VRTK_DeviceFinder.GetControllerRightHand(true);
            while (rightController == null)
            {
                rightController = VRTK_DeviceFinder.GetControllerRightHand(true);
                yield return new WaitForSecondsRealtime(0.2f);
            }
            
            followScript.gameObjectToFollow = rightController;
        }
    }
}
