Phase 2 — Negative Pickup

Nicholas Lim
2 min readJun 15, 2021

--

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.

UI Manager

On the Player the changes are as below:

Player script

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;

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response