Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

Possible bug in Randomizer

A topic by jfam created Jan 09, 2021 Views: 112 Replies: 1
Viewing posts 1 to 2

I was having some issues with the MAST randomizer code. I set up tree randomization for the Modular Terrain Pack of FSP, and noticed that it never picked the first tree out of the set. For each tree I had set up the MAST Prefab Settings script with the following settings:

  • Use Randomizer: True
  • Allow Replacement: True
  • Replacement ID = 1
  • Replacement Weight = 1
  • Allow Sequential Repeat = True

I checked the MAST Randomizer.cs script, and managed to fix it by changing two lines in the CalculateReplacement() function of the Randomizer.cs script. Specifically, I replaced line 128 with "float randomReplaceSeed = Random.Range(1, replaceWeightList.Sum() + 1);", and line 138 with "if (randomReplaceSeed <= replaceWeightRunningTotal)". The problem, I think, is that Random.Range() returns a value exclusive the maximum.

I am not sure if others are having this issue or not, but since I did, I wanted to report it as a possible bug.

Awesome!  Thanks for the fix.  Can you post it in the bugs channel on my discord server?

I will be updating MAST with some major changes in Q1 2021 but not for the next month at least.