Unity2D Devlog 18 — Now You See It, Now You Don’t

Claudio Grassi
2 min readJul 6, 2021

PowerUps can activate powerful weapons, be used to reload ammunition, and heal damage. The Player must take advantage of them to survive. It’s time the Aliens fought back with more devious means.


Allow the enemies to detect and shoot at power-ups that lay in their path.

How I went About It:

I have done most of the work required for this new mechanic. Aliens can already detect the Player and shoot at them. The only thing left to do is to include power-ups in the list of viable targets.
Currently, the Alien Shooting Script uses LayerMasks to identify the Player as a target. I only need to create a new Layer for the power-ups and add it to the Alien Shooting Script.

Next, I need to include a few lines of code in the PowerUp Script.

Taking advantage of the explosion Prefab that the Mimic uses, I can add some visual representation of the destruction of the PowerUp.

I can now call this method from the AlienBullet Script.

The final step is to add a RigidBody2D Component to the PowerUp Prefab. Adding this Component will ensure that both the Bullet and the PowerUp can collide with each other.

Note: For more on this subject, you can read my article on collisions in Unity.

The Aliens will now be able to detect power-ups and destroy them before the Player can reach them. I warn you this can get incredibly frustrating.


Having implemented this mechanic, I realize that it may be a little too drastic. Every Enemy that can shoot will destroy power-ups if they come across them. This ability might turn out to be too powerful. However, I can always include a random element to mitigate its effects later.
For now, I’m happy with the result. The implementation was simple, thanks to how I had previously written the Alien Shooting Script. If only it were always like this.

Claudio Grassi

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.