private bool playerDead; // A bool to show if the player is dead or not. void Awake() { // Setting up the references. animator = GetComponent <Animator>(); playerMovement = GetComponent <PlayerMovement>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <HashIDs>(); enemy = GameObject.FindGameObjectWithTag(Tags.enemy); secondPlayerCamera = GameObject.FindGameObjectWithTag(Tags.secondPlayerCamera); enemySight = enemy.GetComponent <EnemySight> (); }
void Awake() { // Setting up the references. enemySight = GetComponent <EnemySight>(); navMeshAgent = GetComponent <NavMeshAgent>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent <PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <LastPlayerSighting>(); bulletShooting = GameObject.FindGameObjectsWithTag("EnemyBullet"); }
private AnimatorSetup animatorSetup; // An instance of the AnimatorSetup helper class. void Awake() { // Setting up the references. playerHealth = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <PlayerHealth>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; enemySight = GetComponent <EnemySight>(); navMeshAgent = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <HashIDs>(); // Making sure the rotation is controlled by Mecanim. navMeshAgent.updateRotation = true; // Creating an instance of the AnimatorSetup class and calling it's constructor. animatorSetup = new AnimatorSetup(animator, hash); // Set the weights for the shooting and gun layers to 1. animator.SetLayerWeight(1, 1f); // We need to convert the angle for the deadzone from degrees to radians. deadZone *= Mathf.Deg2Rad; }