Living Lightning
|
This week I have created a lightning projectile. In the beginning of the game, two projectiles are available. A basic projectile that simply kills enemies, and an absorbing projectile that will absorb the elemental power of an elemental enemy when it kills it. When the elemental enemy dies, a powerup is spawned which automatically flies over to the player and positions itself on the cloud (the player is flying on a small cloud). If the player dies while carrying a powerup, she will be reborn with that power. In the case of lightning, her basic projectile will change into a lightning projectile that can chain to nearby enemies and prjectiles. Projectiles can’t be destroyed by the lightning, but they serve as a conductor so you can use them to reach the shooter. The way the chain lightning works is, when a lightning projectile is first created, the player sets a counter in the projectile’s code equal to the maximum allowed jumps. If the lightning projectile doesn’t hit anything, it just disappears after a very short time, but if it hits a target, a new “chain” game object gets created on it’s psition. This chain object is basically just a collider that looks for collision with another object within a certain area. If there is a collision, a new lightning projectile is spawned towards that object. The jump counter is decreased and carries over each time there is a chain happening, and eventually either the counter will reach zero, or there won’t be a new target within reach, and the chain will stop. The lightning is supposed to be unpredictable and not fully under the players control. But to avoid situations where the chain arcs around and travels to the left ( back ), I made sure that the chain collider is always aimed toward the right side of the screen, to make sure that the lightning always travels east/northeast/southeast.
We will play around with how many times the lightning is allowed to jump, and if the lightning should be made stronger with other temporary powerups. This was a lot of fun to implement. Making the chain functionality work was difficult and I learned more about manipulating collisions in Unity. |

