Day 49 | Bullet Hell Pattern: 2D Space Shooter Series

Ted Lim
3 min readJun 28, 2021

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 bottom half of the unit circle can represent our semi-circle pattern. We want to create the bullet at coordinate (1,0) first. This will happen at a 0-degree angle. To make X coordinate 1 and the Y coordinate 0 at that angle, we must give the X component the Cos() function and the Y component the Sin() function since Cos(0) is 1 and Sin(0) is 0. Additionally, we will have to convert the degrees to radians (PI/180).

This will be how we place each bullet. Next, we determine the direction of the bullet and normalize the direction vector.

Now that we have the placement and direction, we can use the Object Pooler to create the bullet and set its direction as described in my previous article. Then, depending on how many bullets we want to put into our semi-circle, we increase the angle by some interval and set another bullet’s position and direction until our semi-circle is complete. We then use a Coroutine to space out the interval at which the semi-circle pattern is fired.

Other Shooting Pattern Methods

This is 1 way to create a shooting pattern for a boss. There are less math-intensive ways of creating cool patterns too. For example, you could create an empty game object, spread out 3 child objects from which bullets spawn, and then slowly rotate the parent object to create a spiral pattern of bullets.

Hopefully, this exposes you to the multiple ways to create different bullet-hell shooting patterns.

--

--