コード例 #1
0
ファイル: RayShooter.cs プロジェクト: samartIT/week-12-New-
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         float      posX  = _camera.pixelWidth / 2;
         float      posY  = _camera.pixelHeight / 2;
         Vector3    point = new Vector3(posX, posY, 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)
             {
                 target.ReacToHit();
             }
             else
             {
                 StartCoroutine(ShpereIndicator(hit.point));
             }
         }
     }
 }