Phase 2 — Negative Pickup

For this challenge, I’m to create a pickup that’s actually a debuff of some kind. I’ve decided that this debuff will jam the trigger, making the player unable to fire for the duration of it.

The steps to create the prefab, its spawning code, and duration code is the same as the pickups and collectibles done before, so below is the new, relevant information for how it works.

First, the UI Manager will change what the ammo counter text when the debuff is active, to say “JAMMED” instead.

On the Player the changes are as below:

When the debuff is active, it toggles the _fireLocked bool to true for five seconds, and the player cannot fire lasers for that period.

Something interesting I learned was how to reverse the powerup pickup sound clip, to nail that sound effect of powering down instead.

The most straightforward way to do that is to reverse the pitch of the audio source.

_audio.pitch = -1f;

However, this does nothing in the game, because this tries to play the clip in reverse, and the clip by default starts at zero seconds.

So instead you want the clip’s starting point to be right near the end.

_audio.time = _audio.clip.length - 0.01f;