Пример #1
0
 private void Update()
 {
     if (thrown && hitFloor && animalManager != null)
     {
         Debug.Log("should be here");
         animalManager.BroadcastEventToAnimals <Throwable>("OnFetch", this);
     }
     else if (fetched && animalManager != null)
     {
         animalManager.BroadcastEventToAnimals <Throwable>("OnReturnFetch", this);
     }
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.up, out hit) && Grabbed)
        { // all layers except the second layer(ignore ray cast)
            if (laserDot == null)
            {
                laserDot = Instantiate(laser, hit.point + hit.normal * offset, Quaternion.identity) as GameObject;
            }
            else
            {
                laserDot.SetActive(true);
                laserDot.transform.position = hit.point + hit.normal * offset;
            }

            if (laserLine != null)
            {
                laserLine.gameObject.SetActive(true);
                laserLine.SetPosition(0, transform.position);
                laserLine.SetPosition(1, hit.point);
            }

            if (animalManager != null && hit.transform.CompareTag("Floor"))
            {
                animalManager.BroadcastEventToAnimals <Vector3>("OnLaser", hit.point);
            }
        }

        if (!Grabbed)
        {
            laserLine.gameObject.SetActive(false);
            if (laserDot != null)
            {
                laserDot.SetActive(false);
            }
        }
    }