Home Creators Posts Import Register Favorites Logout

Content

Before I got to work making Magnetized into a status effect, I wanted to test out that the concept would work as viable code. I whipped up a basic magnet sprite so I could see the test object and got to work.

The actual theory was simple: I just needed the magnet to find every nearby bullet and then tell those bullets to apply homing behavior towards the magnet itself. Most of that code was already written—it’s the homing code from the bullets because why wouldn’t I reuse that—but it turns out that actually telling nearby bullets what to do was a little trickier than I thought. I was hoping that I could use a circle collision detection plus the “other” notation to apply the code, but that didn’t work. Luckily, while reading through the GMS2 documentation, I discovered an alternative circle collision that puts everything that it detects into a data list, which was exactly what I needed. Then all I had to do was put it all in a For loop to apply the homing effect.

However, this behavior wasn’t quite enough. I wanted the magnet to be more powerful as the bullets got closer. This would achieve the effect of the bullets repeatedly looping back on the same target which would be ideal for them being magnetically drawn towards the unlucky enemy who would be having a bad day. This too turned out to be simple. I multiplied the homing effect by an equation, #/distance. I think I picked either 100 or 50 for the number, it was arbitrary. And once I remembered to add 1 to that equation so that I wasn’t dividing my homing effect, I got this.

Applying this as a status effect should be incredibly simple seeing as the framework for status effects is already in the game.

I also had the idea for another possible upgrade, but it would affect how the enemy AI functions. We’ll see if it works the way I want it to.

Until next Devlog!

-DeusVerve

DevLogs like these are brought to you by Patron(s) like Haelerin!

Files

Comments

No comments found for this post.