GameMaker Studio 2 D&D blocks - Randomize
In this video we are learning how and when to use Game Maker Studio 2 Drag and Drop Block which is called:
Randomize
This block is part of the Random group of blocks.
It is in the first row, second from the left, with rotated dice on it as icon.
As always you just need to drag and drop it to start using it.
We are going to add it to Create Event, because we need it to be defined only once per game, at it's start.
If we add it to Step Event instead, it will keep randomizing numbers 30 times per second, endlessly, and we don't want that.
In previous video:
GameMaker Studio 2 D&D blocks - Get Random Number
https://youtu.be/ND56yD04g08
we have created some random number generator for our coin value, but after testing it few times it looks like it isn't really random ?
Every time we restart the game we can see that numbers repeat in same pattern.
That doesn't make much sense for games because players will remember the sequence and pattern and use it to their advantage.
Imagine going to casino where you always know what numbers the dice will show, or what cards will be dealed !
Again it is a feature, not a bug, that is how computers work, they do not have imagination or understand randomizing as people.
Unless you tell them to change something computers will not know it is needed or important.
So, we have to add it through one more step and that is what Randomize Action block does.
It shuffles the numbers for us, generating different so called seeds, so we can not recognize repetition easy.
Mostly you need to add this action block to Create Event in your games, on one Object, once only and it will do the trick.
Add it before Get Random Number action block, because we first want to Randomize (shuffle) array of numbers and then pick some numbers from it.
This way it will create different set of numbers on every restart of the game, prevent repetition, and make game more interesting and challenging for player.
Ok, so now we have randomized random number generator, nice !
But it is far from what we need in our game and there are so many other GameMaker Studio 2 Action Blocks to learn,...
So just keep on learning, coding and experimenting !!!