private void Awake() { Agent = GetComponent <NavMeshAgent>(); LinkMover = GetComponent <AgentLinkMover>(); LinkMover.OnLinkStart += HandleLinkStart; LinkMover.OnLinkEnd += HandleLinkEnd; }
private void Awake() { Agent = GetComponent <NavMeshAgent>(); LinkMover = GetComponent <AgentLinkMover>(); LinkMover.OnLinkStart += HandleLinkStart; LinkMover.OnLinkEnd += HandleLinkEnd; LineOfSightChecker.OnGainSight += HandleGainSight; LineOfSightChecker.OnLoseSight += HandleLoseSight; OnStateChange += HandleStateChange; }
private void OnTriggerStay(Collider other) { NavMeshAgent enemyNav = other.transform.root.GetComponent <NavMeshAgent>(); AgentLinkMover mover = other.transform.root.GetComponent <AgentLinkMover>(); if (enemyNav != null && enemyNav.isOnOffMeshLink && !enemyIsWalkingThru) { if (mover != null) { enemyIsWalkingThru = true; StartCoroutine(mover.MoveNavMesh()); } else { enemyNav.CompleteOffMeshLink(); } } }
protected virtual void OnTriggerEnter(Collider other) { if (!isDependent) { if (other.tag == "EnemyNPC") { enemyObj = other.gameObject; enemyNav = other.GetComponent <NavMeshAgent>(); agentLinkMover = other.GetComponent <AgentLinkMover>(); enemyScript = other.GetComponent <Enemy>(); } else if (tag == "Player") { System.Random chance = new System.Random(); int randomInt = chance.Next(0, 100); if (randomInt <= computerCloseChance && doorIsOpen) { StartCoroutine(playComputerSound(computerSound)); Debug.Log("Moving door to closed because 079 decided to"); moveDoor(false); } } } }