Sign in

After implementing our Object Pooler, we’re now going to put together the enemy’s shooting pattern.

The Fan

To make this pattern, we’ll cover a bit of math. If we look closely at the pattern’s origin point, we can see it starts as a small semi-circle. This means we’re looking for a kind of formula to place objects in a semi-circle.

We’ll use Sin() and Cos() to create the semi-circle shape. Assume 10 bullets make up the semi-circle, and we want to create the rightmost bullet first. We can imagine a unit circle like this:

The next feature for our game is a boss battle. Part of the boss battle will include a bullet hell situation where players will dodge a swarm of bullets. To implement the bullet behavior, we will utilize a design pattern known as object pooling.

What is Object Pooling

Object Pooling is the idea of pre-initializing objects so that you don’t have to create and destroy them during runtime. Bullet-hell behavior involves the creation and destruction of many objects during runtime, which can be costly. Object Pooling provides pre-existing objects for the shooting behavior, which should help improve our game’s performance.


Here’s the idea for…

We’re taking a quick break from the Space Shooter series.

One blocker in development is finding the right assets for your game. In this article, I’ll give some tips for where to go to find free assets that can help you fill some of the aesthetic gaps in your games.

Sources This is a great site for indie developers. Not only is it a platform to host games, but it’s also a platform for creators to post assets for public use. When looking for free assets on this site, double-check the license associated with the assets that you’re downloading. Creative…

To counteract the Destroy Powerups feature that we made in the last article, we’ll give the player a Magnet Pickup ability to collect powerups using the ‘C’ key.

Magnet Pickup

After players press the ‘C’ key, if there are powerups in a given radius of the player, the powerups will begin to move quickly toward the player. This makes it easier for players to collect powerups and avoid enemy lasers.

The 2 Key Methods


This method takes a Vector3 position and a float radius value. This will create a ring around our player that will get references to all colliders within its area. …

Continuing our theme of adding more behaviors to our enemies, we’ll give our enemies the ability to shoot and destroy power-up collectibles if they are within a given range.

Destroying Powerups

To make our enemies capable of destroying powerups, we need the enemy to detect the powerup and then sequentially shoot lasers at it.

Detecting Powerups

To detect the powerup, we will make a child Trigger Collider for our enemy prefab. For this child, we’ll attach a Rigidbody2D component and make it Kinematic. Otherwise, the parent enemy object will consider the child collider as part of its own collider.

Continuing to diversify our enemy behavior, in this article, we’ll build an enemy that can shoot lasers behind itself.

A Smarter Enemy

A smart enemy doesn’t shoot lasers haphazardly. A smart enemy will shoot lasers backward only when the player enters its line of sight. This means that the enemy needs a reference to the player to know the player’s position.

Like the Aggressive enemy that we built previously, the enemy inherits its reference to the player from the base enemy class. Therefore, we only need to control when the enemy fires backward toward the player. …

In the next upcoming articles, we’ll focus on adding diversity to our pool of enemies to create more exciting gameplay.

Aggressive Enemy

The aggressive enemy that we will make will detect when the player is within a certain range. Once the player is within the range, the enemy will speed up in an attempt to ram into the player’s ship.

To do this, we need the enemy to know when the player is within a certain distance in front of it. Once in front, we need the enemy to increase its speed.

Detecting the Player

To get the reference to our player, we can do…

Previously, I broadly explained how to build a 2D Space Shooter Wave Manager with Unity Events. In this article, I’ll cover some of the specific information the Wave Manager needs to do its job.

WaveInfo Class

The Wave Manager needs information about each enemy wave. Each wave needs to track the current number of destroyed enemies, the total number of enemies needed to end the wave, and an event to start spawning the wave.

I set up a WaveInfo Class to hold this information:

Each attribute has getter and setter methods. The totalEnemies and waveEvent variables are serialized so that users may…

In this article, we’ll cover how to use Unity Events to control the ordering of enemy waves from the Inspector.

Unity Events

The idea of a Unity Event is to signal when a certain method/behavior should be performed. A basic implementation example can be found here:

What we’re interested in is how to give a designer more control over when these methods are performed. If you serialize a Unity Event, you can control which public method can be played.

In my 2D Space Shooter, I want to create multiple enemy types. Enemies will have different behavior, but they’ll interact with the player similarly. To do this, we’ll change our code so that we have smaller enemy scripts that pull or from a base enemy script.


Ted Lim

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store