Journal 104 — Unity 2D Mobile, Dungeon Escape Loot System with Diamonds

Objective: To add a loot system with collectible diamonds

In this article, I will go over the set up of the diamond collectibles.

First, we need to add the diamond sprite as a new game object. We can also create the diamond C# script.

After creating the diamond game object, we can make the sparkle animation and turn the diamond into a prefab.

After creating the prefab, we can add a Circle Collider 2D, Rigidbody 2D, and Diamond script.

Now we are ready to update the scripts.

Here are the results to check the diamond collectible works.

In each script, we can now instantiate a diamond when the enemy health drops to 0. We can make the instantiated diamond a game object variable, and update its gem value to the base enemy value. In this example, I have a gem value of 5 for the moss giant, 3 for the skeleton, and 2 for the spider.

Here are the results.

One last update is to make sure that if the enemy is dead, there is no way to spawn additional gems.

We can add a check in each Damage() function to simply return out of the function if isDead == true.

Thank you for your time!

--

--

--

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

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

Recommended from Medium

How To Fix BLU Vivo XI+ Not Charging [Troubleshooting Guide]

Validating A Binary Search Tree

Journal 123 — Unity App Development Setup Part 4

10 must have productivity apps for Senior Government Officers

Journal 66 — In “The Great Fleece”, Add Camera Triggers

Why is it important to “Collect All and Save” on Ableton?

Collect All and Save options

The Top Resources for Progressive Web Apps of 2019

Journal 79 — Unity 2.5D Platformer 2.0 with Assets

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
Chris Nielsen

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

More from Medium

Creating an Office Den in Unity Part 2: Lights, Cookies and Emissions

Journal 142 — Unity Project Development, 2.5D Shooter

A Series On Creating Immersive Audio in Unity with Custom Wwise Scripts

IK Weapon System in Unity