Gear VR: Picking up/Moving objects

Hey everyone, I’m fairly new to unity and working on a gear vr app and I’m trying to learn how to interact with items by picking them up using the touch pad controller. I feel like I’m close and was wondering if I can get some insight into the approach I’m taking.

Here’s an image of my scene:

What I’d like to be able to do is pick up the sphere in the middle. Using the scripts from VR Samples [LEGACY] | Tutorial Projects | Unity Asset Store I’ve managed to get a ray to point from the touch controller and recognize the sphere as VR interactive item. I added the following script to the sphere:

using UnityEngine;
using System.Collections;
using VRStandardAssets.Utils;

namespace VRStandardAssets.Examples
{
    // This script is a simple example of how an interactive item can
    // be used to change things on gameobjects by handling events.
    public class ExampleInteractiveItem : MonoBehaviour
    {
        [SerializeField] private Material m_NormalMaterial;               
        [SerializeField] private Material m_OverMaterial;                 
        [SerializeField] private Material m_ClickedMaterial;              
        [SerializeField] private Material m_DoubleClickedMaterial;        
        [SerializeField] private VRInteractiveItem m_InteractiveItem;
        [SerializeField] private Renderer m_Renderer;
        [SerializeField] private float offset;

        private Vector3 OriginalLocation;
        private Vector3 Offset;
        private bool controllerIsHeld = false;

        private void Awake ()
        {
            m_Renderer.material = m_NormalMaterial;
        }


        private void OnEnable()
        {
            m_InteractiveItem.OnOver += HandleOver;
            m_InteractiveItem.OnOut += HandleOut;
            m_InteractiveItem.OnClick += HandleClick;
            m_InteractiveItem.OnDoubleClick += HandleDoubleClick;
            m_InteractiveItem.OnDown += HandleOnDown;
            m_InteractiveItem.OnUp += HandleOnUp;
            OriginalLocation = m_InteractiveItem.transform.position;
            //UpdateLocation.x = m_InteractiveItem.transform.position.x;
        }


        private void OnDisable()
        {
            m_InteractiveItem.OnOver -= HandleOver;
            m_InteractiveItem.OnOut -= HandleOut;
            m_InteractiveItem.OnClick -= HandleClick;
            m_InteractiveItem.OnDoubleClick -= HandleDoubleClick;
            m_InteractiveItem.OnDown -= HandleOnDown;
            m_InteractiveItem.OnUp -= HandleOnUp;
        }


        //Handle the Over event
        private void HandleOver()
        {
            Debug.Log("Show over state");
            m_Renderer.material = m_OverMaterial;
        }


        //Handle the Out event
        private void HandleOut()
        {
            Debug.Log("Show out state");
            m_Renderer.material = m_NormalMaterial;
        }


        //Handle the Click event
        private void HandleClick()
        {
            Debug.Log("Show click state");
            m_Renderer.material = m_ClickedMaterial;


           

        }

        IEnumerator TranslateObj()
        {
           
            for (;;) {
            //m_InteractiveItem.transform.position = Ray.rayEnd + new Vector3 (offset, offset, offset);
                m_InteractiveItem.transform.Translate(offset,0,0);
                yield return null;
            }
        }


        //Handle the DoubleClick event
        private void HandleDoubleClick()
        {
            Debug.Log("Show double click");
            m_Renderer.material = m_DoubleClickedMaterial;
        }

        private void HandleOnDown()
        {
            Debug.Log("button holding down");
            controllerIsHeld = true;
            StartCoroutine ("TranslateObj");
            //m_InteractiveItem.transform.Translate (offset, 0, 0);


        }

        private void HandleOnUp()
        {
            controllerIsHeld = false;
            Debug.Log ("button let go");
            StopCoroutine ("TranslateObj");
            m_InteractiveItem.transform.position = OriginalLocation;
        }


    }

}

such that if the ray hovers over the sphere and I hold a button down, it moves to the left by an offset and when I let go of the trigger while the ray is still hovering over the sphere, it resets to the original position. What i’d like to see is have the position of the sphere change according to wherever the end of the ray is cast. To do this I was thinking of passing a the ray caster into the script and editing the vr eye ray casting script to hold a public value that would represent the end of the ray. I was wondering if this sound like the right way? I apologize if this is common knowledge, but if anyone could point me in a right direction, I would greatly appreciate it!

Hey,
I am trying t do the same thing. Were you able to figure it out?