Beispiel #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (build.canCreateBuild)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, maxDistance, goldLayerMask, QueryTriggerInteraction.Ignore))
            {
                Debug.DrawLine(ray.origin, hit.point, Color.red, 1);
                build.RaycastHitPointBuilder(hit.point);

                if (hit.transform.name == "GoldMine")
                {
                    build.GoldMineHit(true, hit.transform.gameObject);
                }
            }
            else
            {
                build.GoldMineHit(false, null);
            }
            if (Physics.Raycast(ray, out hit, maxDistance, layerMask, QueryTriggerInteraction.Ignore) && hit.transform.name != "GoldMine")
            {
                Debug.DrawLine(ray.origin, hit.point, Color.red, 1);
                //Debug.Log(hit.transform.name);
                build.RaycastHitPointBuilder(hit.point);

                /*if(hit.transform.name == "GoldMine")
                *  {
                *   Debug.Log("GoldMine");
                *   build.GoldMineHit(true, hit.transform.gameObject);
                *  }
                *  else build.GoldMineHit(false, null);*/
            }
            else
            {
                build.GoldMineHit(false, null);
                return;
            }
            //En el else hay que poner que no pille el mar como terrain;
        }
    }