Making a Light Plant
|
This week I started work on a new enemy, and a new mechanic for the game. This enemy is a flower that will sit on a wall and shoot projectiles that provide light, but are also dangerous to the player. The projectiles will also be used later in different puzzles that will interact with them in different ways, opening pathways or providing more light. The plants themselves will also interact in different ways with other projectiles and the player, but these mechanics still needs design work. Making the plant, I started out with drawing a quick sketch of how the code layout should look, and then proceeded to implement it in steps. I first created a prefab for the projectile, testing different lights and collisionboxes to see which would work best. Then I created the actual plant, which really is not much more than a sprite with a trigger collider and a script. The plants script was interesting to implement, to begin with I just instantiated a projetile, adding some force to it, which worked nicely. But then, I had to make it shoot on a timer, which took a good while to figure out. I used the inbuilt function WaitForSeconds(), which works using coroutines, which I did not know how they worked in Unity (well, technically, in C#). I learned a lot about how to use Coroutines with timers, and while I think the final solution I came up with is a bit brittle, I think it will hold well through the development of the game. This plant will be a part of our main core mechanic, so making sure that it works well is imperative. |