void Awake() { // Get all movement behaviours enemy has so that they can be stopped and resumed // IF A CHILD OBJECT OF ENEMY IS HANDLING THE SHOOTING, THERE SHOULD BE NO NEED TO STOP TO SHOOT // THE ANIMATION TO BE PLAYED TO INDICATE SHOOTING IS SEPARATE FROM MAIN ENEMY OBJECT AND SO ENEMY CAN SHOOT AND MOVE AT SAME TIME // STOP TO SHOOT SHOULD ONLY BE IF ENEMY ITSELF IS HANDLING THE SHOOTING WHICH WOULD NORMALLY REQUIRE ENEMY TO STOP MOVING AND PLAY THE SHOOTING ANIMATION movementBehaviours = GetComponents <StoppableMovementBehaviour>(); view = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInView>(); anim = GetComponent <Animator>(); foreach (Transform child in transform) { if (child.tag == "SpawnPos") { spawnPos = child; } } projectilePool = new List <GameObject>(); for (int i = 0; i < poolNum; i++) { projectilePool.Add(Instantiate(shootBehaviour.projectilePrefab, Vector3.down * 50, Quaternion.identity)); projectilePool[i].SetActive(false); } }
void Awake() { anim = GetComponent <Animator>(); lastTrigger = Time.time + 2f; view = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInView>(); shoot = GetComponent <ShootFixed>(); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHP = player.GetComponent <PlayerHP>(); view = player.GetComponent <PlayerInView>(); anim = GetComponent <Animator>(); }
bool playerInView; // Must be in camera view and within distance to be in view (InView and InDistance) void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHP = player.GetComponent <PlayerHP>(); view = player.GetComponent <PlayerInView>(); nextPos = posB; enemyDefaults = GetComponent <EnemyDefaults>(); anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); }
void Awake() { gravity = -1f * gravityScale; collisionMask = LayerMask.GetMask("Ground"); enemyDefaults = GetComponent <EnemyDefaults>(); anim = GetComponent <Animator>(); player = GameObject.FindGameObjectWithTag("Player"); playerHP = player.GetComponent <PlayerHP>(); view = player.GetComponent <PlayerInView>(); }
void Awake() { collisionMask = LayerMask.GetMask("Ground"); player = GameObject.FindGameObjectWithTag("Player"); playerHP = player.GetComponent <PlayerHP>(); playerInView = player.GetComponent <PlayerInView>(); enemyDefaults = GetComponent <EnemyDefaults>(); anim = GetComponent <Animator>(); nextPos = posB; }
bool moveWhileFacing; // Either move while facing player or stop movement and only face player void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHP = player.GetComponent <PlayerHP>(); view = player.GetComponent <PlayerInView>(); movement = GetComponent <StoppableMovementBehaviour>(); anim = GetComponent <Animator>(); // Shoot behaviour must either be in main enemy object which this script is attached to or in child object shootBehaviourScript = GetComponentInChildren <ShootBehaviour>(); // Do not shoot until aggro'd if (shootBehaviourScript != null) { shootBehaviourScript.enabled = false; } }
void Awake() { facePlayer = true; player = GameObject.FindGameObjectWithTag("Player"); view = player.GetComponent <PlayerInView>(); anim = GetComponent <Animator>(); foreach (Transform child in transform) { if (child.tag == "SpawnPos") { spawnPos = child; } } projectilePool = new List <GameObject>(); for (int i = 0; i < poolNum; i++) { projectilePool.Add(Instantiate(shootBehaviour.projectilePrefab, Vector3.down * 50, Quaternion.identity)); projectilePool[i].SetActive(false); } }
void Awake() { view = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInView>(); }