For today’s challenge, I implemented the ability for enemies to shoot power-ups in front of them!
It was a simple implementation. All I needed to do in the PowerUp script was add a check for enemy projectiles in the
if (other.gameObject.CompareTag(“Enemy Projectile”))
Projectile projectiles = other.GetComponents<Projectile>();
for (int i = 0; i < projectiles.Length; i++)
if (projectiles[i].GetIsEnemyLaser() == true)
Destroy(projectiles[i].gameObject); Instantiate(_explosionPrefab, transform.position, Quaternion.identity);
_audioManager.PlayExplosionSound(); Destroy(gameObject, 0.2f);
I also had to make sure the enemy projectile prefabs had the tag “Enemy Projectile” selected.
That was all! Every time an enemy is in front of a power-up and shoots, it will get destroyed. Easy peasy!
That is all for today! Thank you for your time!