Пример #1
0
    void LateUpdate()
    {
        RaycastHit hit;

        if (Physics.Raycast(this.transform.position, this.transform.forward, out hit, _RayLength))
        {
            // If the hit object has a beam controller component...
            if (hit.transform.gameObject.GetComponent <BeamController> ())
            {
                // Return if the hit object's children contrain a beam collision component.
                if (hit.transform.gameObject.GetComponentInChildren <BeamCollision>())
                {
                    return;
                }

                _HitBeamController = hit.transform.gameObject.GetComponent <BeamController> ();
                // Activate it's beam.
                _HitBeamController.ActivateBeam();
            }
        }
        else
        {
            // If no tower is being hit then stop it.
            Stop();
        }
    }