bool isSinking; // Whether the enemy has started sinking through the floor. void Awake() { // Setting up the references. anim = GetComponent <Animator> (); enemyAudio = GetComponent <AudioSource> (); hitParticles = GetComponentInChildren <ParticleSystem> (); boxCollider = GetComponent <BoxCollider> (); enemyMovement = GetComponent <EnemyMovement>(); // Setting the current health when the enemy first spawns. currentHealth = startingHealth; }
void Awake() { // Setting up the references. player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth>(); enemyHealth = GetComponent <EnemyHealth>(); anim = GetComponent <Animator>(); enemyMovement = GetComponent <EnemyMovement>(); nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); GetComponent <SphereCollider>().radius = AttackRange; nav.stoppingDistance = AttackRange; }
void Awake() { // Setting up the references. enemyHealth = GetComponent <EnemyHealth>(); enemyMovement = GetComponent <EnemyMovement>(); anim = GetComponent <Animator>(); targets = new GameObject[3]; targets[0] = GameObject.FindGameObjectWithTag("Ice"); targets[1] = GameObject.FindGameObjectWithTag("Fire"); targets[2] = GameObject.FindGameObjectWithTag("Earth"); playerToAtk = targets[Random.Range(0, targets.Length)]; Ps = playerToAtk.GetComponent <PlayerShield>(); }
public void Shoot() { // Reset the timer. timer = 0f; // Play the gun shot audioclip. gunAudio.Play(); // Enable the lights. gunLight.enabled = true; faceLight.enabled = true; // Stop the particles from playing if they were, then start the particles. gunParticles.Stop(); gunParticles.Play(); // Enable the line renderer and set it's first position to be the end of the gun. gunLine.enabled = true; gunLine.SetPosition(0, transform.position); // Set the shootRay so that it starts at the end of the gun and points forward from the barrel. shootRay.origin = transform.position; shootRay.direction = transform.forward; // Perform the raycast against gameobjects on the shootable layer and if it hits something... if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { // Try and find an EnemyHealth script on the gameobject hit. enemyHealth = shootHit.collider.GetComponent <EnemyHealth> (); EnemyMovement enemyMovement = shootHit.collider.GetComponent <EnemyMovement>(); // If the EnemyHealth component exist... if (enemyHealth != null) { // ... the enemy should take damage. enemyHealth.TakeDamage(damagePerShot, shootHit.point); //enemyMovement.Stun(StunTime); } // Set the second position of the line renderer to the point the raycast hit. gunLine.SetPosition(1, shootHit.point); } // If the raycast didn't hit anything on the shootable layer... else { // ... set the second position of the line renderer to the fullest extent of the gun's range. gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } }
void Awake() { Name = gameObject.name; HP = GetComponent <EnemyHealth>(); MOV = GetComponent <EnemyMovement>(); switch (Name) { case "Hellephant": Bomber = GetComponent <EnemyBomberAttack>(); break; case "ZomBear": Archer = GetComponent <EnemyArcherAttack>(); break; case "ZomBunny": Attack = GetComponent <EnemyAttack>(); break; } }
void Awake() { // Setting up the references. player = GameObject.FindGameObjectWithTag("Player"); playerShield = player.GetComponentInChildren <Shield>(); enemyFreezable = GetComponent <EnemyFreezable>(); anim = GetComponent <Animator>(); enemyAudio = GetComponent <AudioSource>(); hitParticles = GetComponentInChildren <ParticleSystem>(); capsuleCollider = GetComponent <CapsuleCollider>(); movement = GetComponent <EnemyMovement>(); // Setting the current health when the enemy first spawns. currentHealth = startingHealth; enemies.Add(movement); }