Ejemplo n.º 1
0
    public bool IsSeen(GameObject obj, float maxDetectionDistance)
    {
        Hide hide = obj.GetComponent <Hide>();

        if (hide != null && hide.IsObjectHidden())
        {
            return(false);
        }
        Vector3 direction = (obj.transform.position - transform.position).normalized;
        float   angle     = Vector3.Angle(gameObject.transform.forward, direction);

        // Debug.Log(angle);
        if (angle > viewAngle)
        {
            return(false);
        }
        RaycastHit raycastHit = new RaycastHit();
        bool       rayHitted  = Physics.Raycast(transform.position, direction, out raycastHit, maxDetectionDistance);

        if (!rayHitted || raycastHit.collider.gameObject.name != obj.name)
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 2
0
 private void OnTriggerStay(Collider other)
 {
     if (cooldownTimer <= 0.0f && ((other.tag == "Girl" && Input.GetButton("Fire1")) || (other.tag == "Boi" && Input.GetButton("Fire2"))))
     {
         Hide hide = other.gameObject.GetComponent <Hide>();
         if (hide.IsObjectHidden())
         {
             isFree = true;
             hide.UnhideObject();
             ResetTimer();
         }
         else if (isFree)
         {
             isFree = false;
             hide.HideObject();
             ResetTimer();
         }
     }
 }