I was inspired by a game called “Arcanists” to make a destructible 2D platform. I really loved the game and I was excited to make a game just like it. So in my spare time (even sometimes through school lessons) I tried to figure out how to make a destructible platform like that.
Eventually I made an example where you could fire off a projectile to a platform. If it hit the platform it would tear out the part it hit and it would update the collisions so you could continue playing on the map.
It was a really fun personal project.
I made the example on Unity C#. I didn’t really know how I could make something like this at all, so I started by trying to change pixels in a sprite. When I got that working, I made my own circle algorithm that would take each pixel in that circle out of the sprite. The code was very heavy and my game lagged a lot. It wasn’t really the result I was looking for.
I read a lot of articles on the internet on how to achieve such a thing, and I eventually came to a website where they gave a tutorial on how to use shaders. When I understood the whole concept of shaders, I came to the conclusion that shaders were the solution of my problem.
So, in my script I generated an alpha texture for the sprite. If a projectile hit my sprite, I would turn the pixels black on my alpha texture and use the shader to update the sprite.
It worked exactly like I wanted. I love my result now due to it.