Phase II — Progress report — Negative powerup

Luke Duckett
2 min readMay 8, 2021

In this article, I will go over the implementation of the negative powerup I have added— the virus. The implementation was not particularly difficult, but the code did require a refactor for readability.

The virus is a rare, fast-moving powerup that can make the game quite difficult for the player. The virus prevents all movement and drains the hyperdrive and magnet charge. These effects continue until the player's firewall rids the player of the virus.

The powerup calls a function on the player when picked up which stops the hyperdrive and magnet charging routines (if they are currently running) and then calls the coroutine associated with the virus.

The virus coroutine runs a bit of functionality.
First, it plays an event that is heard by the animators (this just prevents some of the movement animations from playing while the virus is active).

Second, it sets the “isVirusActive” bool to active (preventing movement from the player).

Third, it causes the thrusters to flicker and the player colours to change.

Next, the hyperdrive and magnet charges are drained.

Finally, everything is reset.

Now we can see it in action.

--

--

Luke Duckett

🎮 First Nations Unity Dev from Wonnarua country 🏞️ | From Player to Lifelong Learner: Crafting Games, Debugging Code, and Embracing New Technology