/** * Ray cast towards player if within vision cone * If ray cast hits player, i.e. no obstacles between them, then enable guard's pursue behaviour, turning off patrol behaviour */ public void CheckSightForPlayer(GameObject player) { detectPlayer = _detection.CheckIfHit(player); if (detectPlayer.collider != null && detectPlayer.collider.tag == PlayerTag) { _patrolBehav.enabled = false; _sensePlayer = false; SeenPlayer = true; StartCoroutine(ReactToDetection(detectPlayer)); } }
/* * If guard comes in contact with the item they have a 'weakness' towards * Raycast to check if they can see it * If they can see it, activate their corresponding behaviour * NOTE: the node item is in may or may not be used */ public void ReactToWeakness(Collider2D col) { if (col.tag == LootTag && col.GetComponent <Identifer>().ReturnIdentity() == WeaknessItem) { RaycastHit2D detectItem = _detection.CheckIfHit(col.gameObject); Node nodeItemIn = _detection.CalculateNodeLastSeen(detectItem); if (detectItem.collider != null && detectItem.collider.tag == LootTag) { StopExistingCoroutines(); StartCoroutine(ActivateBehaviour(col.gameObject, nodeItemIn, detectItem)); } } }