Create a Loot System in Unity

2D Mobile Game

Objective: Create a loot system where enemies drop diamond with different gem value upon death.

When the enemy dies, instantiate the diamond at the enemy position and set the diamond value to the one defined with respect to the enemy.

Now inside the diamond script, we set the gem value and when the player collects the diamond, player gets either the default diamond value if it was generated by itself or a defined value if it was generated after enemy death.