Esempio n. 1
0
        void Update()
        {
            Vector3 direction = player.position - transform.position;

            ray = new Ray(transform.position, direction);
            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                if (fx == null)
                {
                    fx = hit.collider.GetComponent <TransparentFX> ();
                    if (fx != null)
                    {
                        fx.SwitchMaterial(true);
                    }
                }
                else
                {
                    if (hit.collider.CompareTag("Player"))
                    {
                        fx.SwitchMaterial(false);
                        fx = null;
                    }
                }
            }
        }
Esempio n. 2
0
        void Update()
        {
            Vector3 direction = player.position - transform.position;

            ray = new Ray(transform.position, direction);

            hits = Physics.RaycastAll(ray, Mathf.Infinity, layerMask);
            ClearAllFX();

            if (hits != null)
            {
                for (int i = 0; i < hits.Length; i++)
                {
                    TransparentFX fx = hits[i].collider.GetComponent <TransparentFX> ();
                    if (fx != null)
                    {
                        fxs.Add(fx);
                        fxs[i].SwitchMaterial(true);
                    }
                }
            }
        }