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

How to Build a GeoDjango Web App to Store and Query Locations

Access Denied — Timing Conditional Access with MAM Policy/Approved Apps Enforcement

Creating & Configuring an AWS Account

Air consumption with Python

My second attempt at Pair Programming

Augmented Developers: is AI-Powered coding the future of software development?

SQL Injection Part -3

Know the Differences Between Static and Instance Methods in Java

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

Ease Of Building UI Elements In Unity

Adding Game Over UI elements

How to Create a Custom Hand Painted Skybox

Pushing a box