Summary
We’ve noticed a strange behavior when using GetRandomInt and AddEntities within the same function. The random value returned seems to favor a few numbers. Here’s an example:
RoomDiceRoll := GetRandomInt(0,5)
if(RoomDiceRoll = 0):
InitiateSpawnRoom(SpawnTransform, Prefab_Cave03{})
else if(RoomDiceRoll = 1):
InitiateSpawnRoom(SpawnTransform, Prefab_Cave02{})
else if(RoomDiceRoll = 2):
InitiateSpawnRoom(SpawnTransform, Prefab_Cave01{})
else if(RoomDiceRoll = 3):
InitiateSpawnRoom(SpawnTransform, Prefab_Cave04{})
else if(RoomDiceRoll = 4):
InitiateSpawnRoom(SpawnTransform, Prefab_Cave05{})
else:
InitiateSpawnRoom(SpawnTransform, Prefab_Cave06{})
This code is used to randomly spawn a new room when a player reaches a checkpoint. However, some rooms never spawn after 30+ dicerolls, while others will generate multiple times in a row. We’ve seen the same results running 30+ tests to confirm the issue. It feels like there may be an issue with how random values are generated from SG components.
This issue will not happen if you are merely generating a new number every X frames. It seems to only happen when accompanied by AddEntities or other more intensive processes.
Please select what you are reporting on:
Unreal Editor for Fortnite
What Type of Bug are you experiencing?
Assets
Steps to Reproduce
Create several room sized prefabs of varying complexity. Within the same function, generate a new Int using GetRandomInt and use it to decide which entitiy to add to the scene similar to the above code.
Expected Result
We would expect to see a wide range of random results / layouts.
Observed Result
Certain entries won’t spawn for the first 25+ dicerolls. Other entires will spawn at an above average rate.
Platform(s)
PC