Esempio n. 1
0
    // Latepdate ensures that the object doesn't lag behind the user's head motion
    void Update()
    {
        //set value
        rays        = fove.GetGazeRays_Immediate();
        myEyeStruct = FoveInterface.CheckEyesClosed();
        //raycast
        Physics.Raycast(rays.right, out hit, Mathf.Infinity);

        if (hit.point != Vector3.zero) //&& (myEyeStruct == EFVR_Eye.Left || myEyeStruct == EFVR_Eye.Both))
        {
            transform.position = hit.point;
        }
    }
    // LateUpdate ensures that the object doesn't lag behind the user's head motion
    void FixedUpdate()
    {
        //set value
        rays        = fove.GetGazeRays_Immediate();
        myEyeStruct = FoveInterface.CheckEyesClosed();
        //raycast
        Debug.Log(myEyeStruct.ToString());
        Physics.Raycast(rays.left, out hit, Mathf.Infinity);
        if (fove.Gazecast(hit.collider))
        {
            transform.position = hit.point;

            if (hit.point != Vector3.zero) //&& (myEyeStruct == EFVR_Eye.Right || myEyeStruct == EFVR_Eye.Both))
            {
                transform.position = hit.point;
                //send a message to a destination gameobject

                if (prev == null)
                {
                    //set the prev to the current hit collider

                    prev = hit.collider;
                    Debug.Log("hit collider set collider to my object " + prev.GetType());
                    if (prev.GetComponent <timerScript>() != null)
                    {
                        prev.SendMessage("StartTimer");
                    }
                }
                else if (prev.name != hit.collider.name)
                {
                    if (prev.GetComponent <timerScript>() != null)
                    {
                        prev.SendMessage("StopTimer");
                    }

                    if (hit.collider.GetComponent <timerScript>() != null)
                    {
                        hit.collider.SendMessage("StartTimer");
                    }

                    prev = hit.collider;
                }
            }
        }
    }