Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            audioSource.PlayOneShot(shotSound);

            Vector3    point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0.0f);
            Ray        ray   = _camera.ScreenPointToRay(point);
            RaycastHit hit;

            Debug.DrawRay(ray.origin, ray.direction);

            if (Physics.Raycast(ray, out hit))
            {
                //Debug.Log ("Hit " + hit.point);

                ;

                GameObject     hitObject = hit.transform.gameObject;
                ReactiveTarget target    = hitObject.GetComponent <ReactiveTarget> ();
                if (target != null)
                {
                    target.reactToHit();
                }
                else
                {
                    StartCoroutine(SphereIndicator(hit.point));
                }
            }
        }
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector3    point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
         Ray        ray   = _camera.ScreenPointToRay(point);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             GameObject     hitObject = hit.transform.gameObject;
             ReactiveTarget target    = hitObject.GetComponent <ReactiveTarget>();
             if (target != null)
             {
                 Debug.Log("Target Hit!");
                 target.reactToHit();
             }
             else
             {
                 StartCoroutine(sphereIndicator(hit.point));
             }
         }
     }
 }