Phase II — Progress report — Negative powerup

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.




Unity developer with a love of learning all things programming.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Android: an idiom for Activity parameters (in Kotlin)

Making Android-Activity Great Again !!!

How To Collect Flows Lifecycle-Aware In Jetpack Compose

Time lapse photography of waterfalls

Implement Continuous Speech Recognition on Android

Android Retrofit, RecyclerView, SearchView Usage

Tabletop mode on foldable devices

Intro to Kotlin Coroutines

Ionic Android Error while merging dex archives — Unable to merge dex in Ionic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luke Duckett

Luke Duckett

Unity developer with a love of learning all things programming.

More from Medium

Set Lasers To Destroy

Script communication in unity using GetComponent:

Quick tip — Enabling post-processing in Unity Universal Render Pipeline

Converting from 3D to 2D in Unity