detect player stealth unity code example

Example: detect player stealth unity

if(LeftRightZ)         {             if(EyeScanZ < 30)             {                 EyeScanZ += 100 * Time.deltaTime;             }             else             {                 LeftRightZ = false;             }         }         else         {             if (EyeScanZ > -30)             {                 EyeScanZ -= 100 * Time.deltaTime;             }             else             {                 LeftRightZ = true;             }         }         transform.Find("MEyes").transform.localEulerAngles = new Vector3(0, EyeScanZ);           RaycastHit hit;         Debug.DrawRay(transform.Find("MEyes").position, transform.Find("MEyes").transform.forward * ViewDistance);          if (Physics.Raycast(transform.Find("MEyes").position, transform.Find("MEyes").transform.forward * ViewDistance, out hit, ViewDistance))         {             if(hit.transform.gameObject.tag == "Player")             {                 Debug.Log(gameObject.name + " CAN see Player");             }          }

Tags:

Misc Example