Creating Ammo Collectable in Unity

Objective: create a collectable to add more ammo when the player collects it

First I dropped a sprite in the scene, modified the size and added the components (collider and rigidbody) to create the ammo prefab.

Also I added the powerup script to this prefab because it is gonna have the same behaviour than a powerup. The player collects it and executes something.

In the SpawnManager Object I added the ammo prefab to the powerup array.

In the player script I created a function called “AddAmmo” to modify the value of the ammo variable and update the UI.

Next in the powerup script I added a new case to call the function to add ammo.

And that’s it! Ammo collectable ready.

--

--

--

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

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

Recommended from Medium

A Buyer’s Guide to IT Asset Management Software

A Buyer’s Guide To Cloud-Based IT Asset Management Software

Make JPA Queries generic to support multiple optional fields.

Improve your tests with Kotlin in Android — (Pt. 3)

Building Bookshop: Stocking over 10M Books with Ingram

Huge stack of books

Azure Table Storage with Clojure

How to Deploy a CentOS Linux VM in Azure using Terraform

How to make money from sdk ?

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
Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

More from Medium

Damage VFX Using Animated Sprites In Unity

Animating Sprites in Unity

Day 105: Working with Animation Events in Unity

Unity highlight text instead of button