Let’s Loot Enemies- Game Dev Series 108

Objective: create loot system.

When we have a fully functional enemy, it is time to add some prize that Player can collect.
In this article, we will create a loot system.

Function of diamond prefab

First we need a diamond prefab as prize. Create a diamond prefab from sprite with shining animation. Once prefab is ready, create a script and attach to it.
We will make this prefab be collectable by Player and add diamond amount to Player.

Create this “AddDiamond(int)” function to Player script.

Now we need to add the reference of diamond to all the enemies.
Open Enemy script and add another variable.

Back to inheritance enemy script and instantiate the prefab after death.

Set the gems integer in editor, and the enemy would drop the number of diamond(value) after death.

Copy the last 2 lines to all enemies and do the same setting, then everything would be done!

--

--

--

A passionate gamer whose goal is to work in video game development.

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

Recommended from Medium

The need for speed - Experimenting with message serialization

Evaluating Critical Performance Needs for Microservices and Cloud-Native Applications

Spec and Quality

Flask Application Discovery Explained

Bootcamps: a course or a recruitment agency?

Snake Game With Python

Generics — Java 11

Migrating data from Cloud Firestore to Cloud SQL

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
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

How I used scriptable objects to build a powerup system

Building a Custom Cinemachine Virtual Camera Zoom Feature with One Button in Unity

Creating Elevator in Unity — Part 3: Moving Elevator.

New Pooling API in Unity 2021