////////////////////////////// Action: IDLE ////////////////////////////// void ActionInit_Idle() { navMeshAgent.SetDestination(startingPos); navMeshAgent.isStopped = false; //Q1: The player has been lost or killed. The static variables (rifleSolider & shotgunSolider) are now updated. if (rifleSolider == this) { rifleSolider = null; } else if (shotgunSolider == this) { shotgunSolider = null; } }
void AlertEnemies() { RaycastHit[] hits = Physics.SphereCastAll(hitTestPivot.position, 20.0f, hitTestPivot.up); foreach (RaycastHit hit in hits) { if (hit.collider != null && hit.collider.tag == "Enemy") { NPC_Enemy_DT dt = hit.collider.gameObject.GetComponent <NPC_Enemy_DT>(); if (dt != null) { dt.SetAlertPos(transform.position); } NPC_Enemy_FSM fsm = hit.collider.gameObject.GetComponent <NPC_Enemy_FSM>(); if (fsm != null) { fsm.SetAlertPos(transform.position); } } } }
void OnCollisionEnter(Collision collision) { if (collisionTarget == CollisionTarget.PLAYER && collision.gameObject.tag == "Player") { collision.gameObject.GetComponent <PlayerBehavior>().DamagePlayer(); } else if (collisionTarget == CollisionTarget.ENEMIES && collision.gameObject.tag == "Enemy") { NPC_Enemy_DT dt = collision.gameObject.GetComponent <NPC_Enemy_DT>(); if (dt != null) { dt.Damage(); } NPC_Enemy_FSM fsm = collision.gameObject.GetComponent <NPC_Enemy_FSM>(); if (fsm != null) { fsm.Damage(); } } else if (collision.gameObject.tag == "Finish") { //This is to detect if the proyectile collides with the world, i used this tag because it is standard in Unity (To prevent asset importing issues) DestroyProyectile(); } }