Your cart is currently empty!

Sounds, Loot, Enemies, & More – How to Randomize in GDevelop
Hey fellow game developer. I’m ACP_Nate. Today, let’s explore RANDOMIATION!!! In this guide, we will generate random monster sound effects. However, you can apply this logic to all types of randomization in GDevelop. If you are knew to Variables, this lesson will also introduce variables to you as well. So, let’s dive in – Sounds, Loot, Enemies, & More – Randomize in GDevelop!
👉 YouTube Tutorial: How to Randomize Sound FX, Loot, Enemies & More in GDevelop
Step 1: Gather the Options to Randomize in GDevelop
Randomization keeps players coming back to your game, because its constantly fresh and fun. Since we will focus on sound fx for this randomization tutorial, we need 4 zombie sounds. To begin, download 4 monster sound fx on Pixabay – you can edit these effects with Audacity. I usually save sound fx as MP3 files. Then, upload those audio files to GDevelop so we can work with them.

Oh and don’t forget to make a Character/Player and a Monster/Enemy🙂 You’ll need those sprites and apply some form of movement to the Character for this tutorial. If you do not know how to make a player or monster, do a quick YouTube search.
What are GDevelop Variables?
Think of variables as control switches. Some are on/off toggles (Boolean variables). Others work like dials with many possible outcomes (Array and Structure variables). In addition, you also have Number variables for counting and Text variables for words and phrases.
Step 2: Create Global Variables
Ok, so now you understand variable types. Let’s create the variables needed for our sound fx randomization tutorial.

First, click the hamburger menu in the top-left and choose Global Variables. You can assign variables to objects or scenes, but for now, focus on global settings.
Next, click the plus sign (+) in the top-right. Then, choose Number from the dropdown and name it RandomValue
. This variable will generate your random number — the backbone of your randomization.

Then, set up your options with an Array variable called MonsterSound
. Now, add four children: Child 0 = z1, Child 1 = z2, Child 2 = z3, Child 3 = z4
Finally, create a Text variable named ChosenMonsterSound
.
Remember: GDevelop is case-sensitive and spacing is also accounted for. Therefore, use exact spelling, spacing, etc.
Step 3: Generate the Events, Enabling Randomize in GDevelop
Now for the fun part — generating the events for randomness!!!

NOTE: Right-click the vertical rectangle next to your condition. Then, Select Add Sub-condition → Repeat. This will generate a condition with the Repeat feature.
ADDITIONAL NOTE: The timer condition and action is optional. I used timer as a control to prevent excessive sound fx triggering. You can exclude the timer, if you’d like. But, if you choose to keep it, remember to also add Start (or reset) the Timer “ZombieFX” at the beginning of the scene.
Also, carefully follow the text in the image above. To clarify, be sure to add the ( ) and [ ] in all the correct locations. One slip-up and it may break the event. If it does not work, carefully doublecheck spelling, capitals, etc.
Why the -1 at the end?
Great question and attention to detail! Well, one of your array’s children starts at 0. So, the “-1” includes that child as a possible result. If we did not have the -1, then the 0 Child would never be a possibility because the RandomValue would always begin at 1.
Once you complete these events, this connects your RandomValue variable to the matching text label, MonsterSound Child in the array. And, once the event’s initial condition is triggered, you should hear one-of-the-four possible sound fx.
Step 4: Keep Experimenting
Once you’ve done this a few times, you’ll start to randomize in GDevelop often. It keeps your game replayable and dynamic. You can use the same logic for enemies, loot, or background music.
Check out my game Truth: Save the Miners! — you’ll see that I used randomization for sound effects, treasures, and even enemy spawns.Random Sound FX, Songs, Treasures, Enemies, and More in GDevelop.
Now you know how to randomize sounds, loot, enemies, & more in GDevelop!

👉 YouTube Tutorial: How to Randomize Sound FX, Loot, Enemies & More in GDevelop