Loot makes the world go around. Creating a simple loot system in Unity.
A short one today but a fairly common mechanic to go over.
Loot is an essential part of a games loop. A very common thing is for enemies to drop loot, pickups, etc when killed. Creating a system for this can be quite simple and to get the results shown in the image above I had done the following.
When the enemy is killed, I would simply instantiate the loot item, in this case the diamond. The second part of this is that each enemy would have a different value of diamonds dropped and using a simple GetComponent, I would just set the gem value of to equal the enemies gem value.
The pickup would be handled by a Diamond script with a simple OnTriggerEnter and would call a method on the player script.
Although I see this as simple now, my first project I was just trying to wrap my head around script communication. Although it may not be much in the grand scheme of things, the progress I have made is extremely exciting to me and I can’t wait to go further.
See you next post.