Exemplo n.º 1
0
    void OnTriggerExit(Collider collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            PlayerDetected = null;

            if (LostPlayer != null)
            {
                LostPlayer(collision);
            }
            if (LostPlayerCoroutine != null)
            {
                SenseEventHandler func = LostPlayerCoroutine;
                StartCoroutine(func(collision));
            }
        }
        else
        {
            if (OtherDetected == collision.transform)
            {
                OtherDetected = null;
            }
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter(Collider collision)
    {
        // check viewing angle
        if (Angle > Mathf.Epsilon && Mathf.Abs(Vector3.Angle(transform.forward, (collision.transform.position - transform.forward))) > Angle)
        {
            return;
        }


//		Debug.Log (SenseName);

        if (collision.gameObject.tag == "Player")
        {
            PlayerDetected = collision.transform;

            if (SensedPlayer != null)
            {
                SensedPlayer(collision);
            }
            if (SensedPlayerCoroutine != null)
            {
                SenseEventHandler func = SensedPlayerCoroutine;
                StartCoroutine(func(collision));
            }
        }
        else
        {
            OtherDetected = collision.transform;
            if (Sensed != null)
            {
                Sensed(collision);
            }
            if (SensedCoroutine != null)
            {
                SenseEventHandler func = SensedCoroutine;
                StartCoroutine(func(collision));
            }
        }

//		Debug.DrawRay(transform.position, collision.transform.position - transform.position, Color.white);
//
//		Debug.Log ("Sense triggered");
//
//
//		if (collision.gameObject.tag == "Crowd") {
//			Debug.Log ("Collided with crowd");
//
//			if (Random.value < 0.05)
//			{
//				Debug.Log ("Starting to chat");
//			}
//		}
//
//		if (collision.gameObject.tag == "Player") {
//			Debug.Log ("Player triggered");
//
//
//			_lookAt = collision.gameObject.transform;
//
//			// transform.LookAt (collision.transform.position);
//
//			if (Random.value < 0.05)
//			{
//				Debug.Log ("Starting to chat");
//			}
//		}
    }