Lasers! Pew pew pew!
Dev Diary 18
Lasers - what would be life without them. In Elfscape: Ancestors, lasers are used quite frequently - not only as obstacles for the player, but we also use them as a solution to certain level design problems. For example, when the character was pushed into the wall by some obstacles, it used to get stuck there. Now, the obstacles that used to push players are made of lasers. So instead of getting pushed and getting stuck, the character gets hurt by a laser - it still makes the player want to avoid the obstacle, and it’s an easier solution for us.
Now, let's take apart our rotating lasers and see what they're made of. It's basically 3 things. Texture, material and a script.
The texture is made in Krita, using wrap around mode, which helps in creating seamless textures. We choose the material which makes the texture roll in Unity. Andfinally, a script which can alter the rolling speed.
In this short video, we’ll show you different laser usages.
In the last part of the video, you can see a “broken” laser. If you’re interested in what broke it, here’s a short explanation:
In Unity, new graphics additions (sprites) don't have to have their own file, but they can be packed together into something called a Sprite atlas. It is used to optimize the performance when loading graphics files, especially useful for making the game run smoothly on low-end devices. You can combine different types of graphics into a Sprite atlas (imagine a grid filled with multiple pictures), and when the game needs to load new graphics, instead of loading lots of smaller files with one picture, only one file with multiple pictures is loaded. But here comes the catch. When we apply the “rolling material” to the texture we want to use for a laser, and the texture is a part of some Sprite atlas, the material applies to a whole Sprite atlas sheet. So instead of the one rolling picture, we get a roll-through of the entire Sprite atlas. And that’s what you can see in the “broken” laser video.