Member-only story

Unity2D DevLog 14 — Randomizing Based on Rarity

Claudio Grassi
3 min readJun 4, 2021

Not all items are created equal. Any game that uses a loot-drop system categorizes its items by rarity. At the moment, all of my power-ups and enemies have an equal chance of being created. I want to change this and create a Spawn System that relies on rarity.

Objective:

Create a system that takes rarity into account when spawning enemies and power-ups.

How I went about it:

In a previous Devlog, I talked about creating a wave spawning system. Part of this system includes a list of Aliens for each wave. I want to control the probability for each alien. Likewise, I want to apply this system to power-ups.

The first thing I had to do was create a way to assign a rarity level to each item. I called this the item’s weight.
The WaveData has an Array of enemies in each wave. It uses this array to choose which enemy to create. To control this better, I can assign a weight value to each enemy.

I can edit the values in the inspector and decide how often each item should appear.

--

--

Claudio Grassi
Claudio Grassi

Written by Claudio Grassi

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.

No responses yet