コード例 #1
0
    void Update()
    {
        FoveInterface.EyeRays             rays = fove.GetGazeRays();
        FoveInterface.GazeConvergenceData gcr  = FoveInterface.GetGazeConvergence();
        //FoveInterface.CheckEyesClosed();
        Debug.Log(gcr.accuracy);
        RaycastHit hit;

        if (Physics.Raycast(rays.left, out hit, 25))
        {
            //hit.transform.GetComponent<timerScript>().startCounting();
            if (hit.point != Vector3.zero) // Vector3 is non-nullable; comparing to null is always false
            {
                // Debug.Log(hit.point);
                transform.position = hit.point;
                x   = hit.transform.tag;
                vec = hit.point;
            }
        }

        if (x == "Player")
        {
            if (Vector3.Distance(prev, vec) > 0.9 || prev == Vector3.zero)
            {
                prev = vec;
                if (c < count)
                {
                    pcount         = c;
                    positions[c++] = new Vector4(vec.x, vec.y, vec.z, 0);
                    Debug.Log(c + ":" + count);
                }
                else
                {
                    if (c >= count)
                    {
                        Debug.Log("this is end");
                        c = 0;
                    }
                }
            }
            else
            {
                if (properties[pcount].y < 1.0)
                {
                    properties[pcount] += new Vector4(0, 0.005f, 0, 0);
                }
            }
        }

        for (int i = 0; i < positions.Length; i++)
        {
            positions[i] += new Vector4(UnityEngine.Random.Range(-0.1f, +0.1f), UnityEngine.Random.Range(-0.1f, +0.1f), 0, 0) * Time.deltaTime;
        }

        material.SetInt("_Points_Length", count);
        material.SetVectorArray("_Points", positions);
        material.SetVectorArray("_Properties", properties);
    }
コード例 #2
0
    private void InFrontUpdate()
    {
        nma.destination = transform.position;
        inFrontTime    -= Time.deltaTime;

        RaycastHit hit;

        if (Physics.Raycast(fove.GetGazeRays().left, out hit, 1000f, 1 << 10))
        {
            if (Mathf.Abs(transform.position.z - hit.point.z) > .5f)
            {
                nma.destination = new Vector3(transform.position.x, transform.position.y, hit.point.z);
            }
        }

        if (inFrontTime <= 0)
        {
            currPhase       = Phase.End;
            nma.destination = CharEndLoc.position;
            StartCoroutine(ChangeLooking(2f, false));
        }
    }