You spin my head
|
The project for this week was to implement a second power-up. As the first power-up gave the player a giant meteor to incinerate the enemies, the new power-up will be more defensive. When talking about defense a lot of people will probably think of shields, and that is just what i made. A fire shield. When the player activates the power-up a fire shield will spawn around the player and follow them around for a few seconds. Any enemies that touch the shield will be burnt to a crisp. The first thing was to make the fire shield spin around to give it a more fiery feel. To do that i added the same hinge joints i used to make the ravens spin, so that was easy. Next i needed the shield to be able to be activated and deactivated, so to not have a impenetrable wall of death. First i tried using the same method as the shooting for both the fireballs and the meteor, setting a spawn-point for it and inside the player script ”fire” a shield that would stick around the player. But when i got the player to spawn the shield it didn’t spin because the object i had spawned did not have the player assigned as its connected body. After trying to assign it with code, and failing, i look for a different method. This was when i found unity’s ”SetActivated(true/false)” which could control whether a object is active or not. This could work if i made the shield attached to the player from the start but deactivated it so it couldn’t be seen. But after some testing i realized that by deactivating the shield it stopped getting input and could therefore not be reactivated. After some googling i found the solution. By making the shield a child of something, i could control the activation process form inside that instead. I made the other raven i created to the parent of the shield and implemented the functionality of the activation and deactivation in there. I also added the same signaling system as for the meteor power-up, where the raven lights up after a set amount of time to signify the player that the power-up is ready for use. And with this the game now have tow power-ups. |
