43: Negative Collectable

Objective: Upon collection of this powerup Scale up the player to allow for easier hit from Enemies.

For this negative collectable / powerup is to set up the object to be collected. We’ll throw the sprite in the hierarchy and set it up like all the other collectables we’ve done on this journey. The object will need the Powerup Script, Box Collider2D (or any collider you feel is good for it) and make sure isTrigger is checked, and Rigidbody2D, make sure gravity is set to zero.

Make sure to assign the correct powerupID and weight you would like the Powerup to be spawned.
In the player script we will need to scale up the player and revert it back to the original size. We need two new vector3 variables, one for the scaleUp and one for the original scale to revert back to.

In the start function we are going to assign the originalScale to transform.localScale. This will allow up to keep the scale to how we set it up in the inspector.

Now it’s time to create a function that scales the transform.localScale up to the scaleUp variable and call the Coroutine to start the timer to scale back down.

When the coroutine is finish it’ll assign the transform.localScale back to the originalScale that we created.

The player side is now finish, we will move over to the powerUp script to call the negitivePowerup function. We’ll add a new case with the associated powerupID and call the function.

This is a small negative power up that’ll make it a little hard to start safe while playing!

--

--

--

I am passonate on learning to program and use Unity to become a skillful Unity Developer

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

Recommended from Medium

How To Reduce Your App’s APK Size, Even If You Use Realm

48: Balancing enemies

Why Should We Use the App Bundle? Release App Bundle on AppGallery

Jetpack compose — Dependency injection with Dagger/HILT

Hands on with Jetpack’s Security App Authenticator library

Coin Hunt World v1.0.2.131

Lifecycle for Android Developers (Part 2)

Understanding the Constraint Layout in Android

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
Tyler Smallwood

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

More from Medium

Different Lights in Unity.

Cinematography in Unity — Skyboxes

Adding a collectible ammo charge powerup

How to Set Up a Simple Drop-Loot System in Unity