Ejemplo n.º 1
0
        // cast a ray in the specified direction and call any SampleController.TriggerEnter found
        private void Scan(Vector3 direction)
        {
            // Draw a debug ray for the scanner line
            Debug.DrawRay(transform.position, direction);

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

            // Get a Raycast Hit (and save it for the hinge position)
            if (Physics.Raycast(origin, out hit, 100))
            {
                SelectionController sampleHit = hit.collider.gameObject.GetComponent <SelectionController>();
                // If something is already indicated, check if it's different from currently indicated
                if (indicated != null && !indicated.Equals(sampleHit))
                {
                    indicated.TriggerLeave();
                }

                // Debug.Log("There is " + hit.collider.gameObject.name + " detected");
                indicated = sampleHit;
                if (indicated != null)
                {
                    indicated.TriggerEnter(hit.collider.gameObject);
                }
            }
            else if (indicated)
            {
                indicated.TriggerLeave();
                indicated = null;
            }
        }