// Use this for initialization void Start() { nmo = transform.FindChild("SmallAlienMesh").GetComponent <NavMeshObstacle>(); health = gameObject.GetComponent <SmallAlienHealth>(); AlienPhysics = gameObject.GetComponent <SmallAlienPhysicsManager>(); ai = gameObject.GetComponent <SmallAlienAI>(); walkSpeed = 1f; GameObject SmallAlienNavmeshAgent = (GameObject)Instantiate(SmallAlienNavmeshAgentPrefab, transform.position, transform.rotation); _SmallAlienAgent = SmallAlienNavmeshAgent.GetComponent <NavMeshAgent>(); anims = gameObject.GetComponent <Animator>(); ToggleNavmeshAgent(true); target = GameObject.Find("PlayerSpawnLocation"); startDistanceFromPlayer = Vector3.Distance(transform.position, target.transform.position); FindAttackPosition(); // Added by Matt attackingPlayer = true; /* * //debug target * target = GameObject.Find("debugNavmeshtarget"); * SetNavMeshAgentDestination(target.transform.position, true, target); */ }
// Use this for initialization void Start() { currentHealth = health; ai = gameObject.GetComponent <SmallAlienAI>(); Physics = gameObject.GetComponent <SmallAlienPhysicsManager>(); anims = gameObject.GetComponent <Animator>(); }
// Use this for initialization void Start() { currentHealth = health; ai = gameObject.GetComponent <SmallAlienAI>(); Physics = gameObject.GetComponent <SmallAlienPhysicsManager>(); anims = gameObject.GetComponent <Animator>(); Reticle = GameObject.Find("Reticle").GetComponent <HitMarkerScript>(); }
// Use this for initialization void Start() { rb = gameObject.GetComponent <Rigidbody>(); anims = gameObject.GetComponent <Animator>(); ai = gameObject.GetComponent <SmallAlienAI>(); health = gameObject.GetComponent <SmallAlienHealth>(); nav = gameObject.GetComponent <AlienNavMeshInterface>(); mesh = gameObject.transform.FindChild("SmallAlienMesh").gameObject; startEmission = mesh.GetComponent <SkinnedMeshRenderer>().material.GetColor("_Emission"); startDrag = gameObject.GetComponent <Rigidbody>().drag; startY = transform.position.y; }
// When the alien get's close to the dummy, it'll attack it. void OnTriggerEnter(Collider other) { if (other.tag == "Alien") { distractedAliens[distratedAliensIndex] = other.transform.parent; distratedAliensIndex++; AlienNavMeshInterface thisAlien = other.GetComponentInParent <AlienNavMeshInterface>(); SmallAlienAI thisAlienAI = other.GetComponentInParent <SmallAlienAI>(); thisAlien.target = gameObject; thisAlienAI.SetState(SmallAlienAI.States.Navigating); thisAlien.attackingPlayer = false; health.healthRateMultiplier += drainHealthMultiplier; } }
// When the dummy get's destroyed, all of the aliens on it will move back to the player. void OnDestroy() { for (int i = 0; i < distractedAliens.Length; i++) { if (distractedAliens[i] != null) { AlienNavMeshInterface thisAlien = distractedAliens[i].GetComponent <AlienNavMeshInterface>(); SmallAlienAI thisAlienAI = distractedAliens[i].GetComponent <SmallAlienAI>(); thisAlien.target = playerLoc; thisAlienAI.SetState(SmallAlienAI.States.Navigating); thisAlien.FindAttackPosition(); thisAlien.attackingPlayer = true; } } }
// When the dummy get's destroyed, all of the aliens on it will move back to the player. void OnDestroy() { for (int i = 0; i < distractedAliens.Length; i++) { if (distractedAliens[i] != null) { AlienNavMeshInterface thisAlien = distractedAliens[i].GetComponent <AlienNavMeshInterface>(); SmallAlienAI thisAlienAI = distractedAliens[i].GetComponent <SmallAlienAI>(); thisAlien.target = playerLoc; thisAlien.SetNavMeshAgentDestination(playerLoc.transform.position); thisAlienAI.SetState(SmallAlienAI.States.Navigating); thisAlien.nmo.enabled = false; thisAlien.attackingPlayer = true; } } }