New Weapon — A The Binding of Isaac-style continuous laser beam

Daniele Quero, PhD
4 min readAug 6, 2021

Objective: Implementing a new — really funny — weapon with almost zero effort and no new asset

This is the kind of tutorial I love the most: recycle, reuse and make something new out something old just with a little of imagination. Of course, having fun doing so!

Courtesy of https://bindingofisaacrebirth.fandom.com/wiki/Brimstone

Did you ever play The Binding of Isaac? In that game there’s a power up, the brimstone: a lovable, funny power up for player “weapon", and also quite brutal.

This weapon consists of a continuous beam that lasts for a given time and can be produced at a given rate. While the beam is on, it can damage things again at a given rate.

I always loved it and I want to put it in my game.

But I’m no artist

Yep. I am no artist. How can I possibly reproduce that cool bean effect? Well, let’s be smart!

First I’m going to use a copy of the laser sprite, the one we already used for default shooting. The beam effect is going to be easier than you can imagine: animation. Yes we learned how to animate sprites using sprite sheets and also through properties manipulation. The second one is the way.

We’re going to “animate” the scale property of this new laser sprite, making it bigger in width (x-scale) and height (y-scale) to how much we think is fine and then back to zero.

Again we’re going to use the curves, which are my favourite tool at this moment. As you can see I tried to put a peak in x-scale and y-scale, different values but close in time (i.e. key frame).

The effect would be the one of a beam starting from the ship and elongating forward while also widening. To do so, again we need to change the settings and position of pivot in the sprite, otherwise the rescaling would appear as starting from the very centre of the beam. Ugly.

Add the 2D box collider to the object now, and notice how it perfectly rescale along with sprite: thank you kindly, Unity! Don’t forget: it’s a trigger just like the laser.

In terms of layers and transition we have nothing to do: I want the beam to animate as soon as the object is instantiated and to die when the animation ends. This is a matter of script.

So, as soon as the “death ray” (so cute) is born, it is going to be destroyed after a — finely tuned — time, and it is set as child to the player: unlike the simple laser pulse, this beam will move with the player.

In order to reproduce a damage over time (DoT), I used the OnTriggerStay method. It is quite similar update: it will execute the code at each (physical) update, but only while a trigger is inside the other. I implemented a cooldown logic (just like firing cooldown) in order to have a damage each _hitRate seconds. The damage itself is managed by the other trigger script.

In order to shoot like this I also added a new power up, with very rare spawning, that will work just like the tripleshot: a bool is set true and then false after a time (5s), while it is true the prefab instantiated at each shot is different than default. Easy.

Let’s look at the result.

--

--

Daniele Quero, PhD

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams