# How to have random number with a packaged game?

**URL:** <https://forums.unrealengine.com/t/how-to-have-random-number-with-a-packaged-game/318747>\
**Category:** Platform & Builds\
**Tags:** random, random-numbers, unreal-engine, bug-report, packaging-projects, question\
**Created:** [May 15, 2015, 4:40pm UTC](https://forums.unrealengine.com/t/how-to-have-random-number-with-a-packaged-game/318747 "2015-05-15T16:40:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2cd5b13d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2cd5b13d](https://forums.unrealengine.com/u/anonymous_user_2cd5b13d)\
**Post date:** [May 15, 2015, 4:40pm UTC](https://forums.unrealengine.com/t/how-to-have-random-number-with-a-packaged-game/318747/1 "2015-05-15T16:40:05Z")

</div>

Hello everyone !

I am making a procedural generated world. To do that, I am using FMath::RandRange(min, max). In the editor, every time I am playing, I get perfectly random numbers. But, when I package the game, it is always the numbers that are picked, and my game always look the same !  
I think the problem is the seed of the number generator, but when I use srand(time(NULL)) I can’t compile or play the game in the editor !

This look like a bug from the engine so if you have any way to fix it, please, let me now !

Thank you !

---

<div class="post-metadata">

**Author:** ![Pierdek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pierdek](https://forums.unrealengine.com/u/Pierdek)\
**Post date:** [May 16, 2015, 8:18pm UTC](https://forums.unrealengine.com/t/how-to-have-random-number-with-a-packaged-game/318747/2 "2015-05-16T20:18:18Z")

</div>

You should merge to your engine code:

[https://github.com/EpicGames/UnrealEngine/commit/edce4b6ff1b1c359d8fe156bccfc20c74af4b4fa](https://github.com/EpicGames/UnrealEngine/commit/edce4b6ff1b1c359d8fe156bccfc20c74af4b4fa)

But if you can’t  
use this:

```
uint32 Cycles1 = FPlatformTime::Cycles();
FMath::RandInit(Cycles1);
uint32 Cycles2 = FPlatformTime::Cycles();
FMath::SRandInit(Cycles2);

```

from the link.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2cd5b13d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2cd5b13d](https://forums.unrealengine.com/u/anonymous_user_2cd5b13d)\
**Post date:** [May 16, 2015, 9:12pm UTC](https://forums.unrealengine.com/t/how-to-have-random-number-with-a-packaged-game/318747/3 "2015-05-16T21:12:50Z")

</div>

Thank you very much now it works perfectly !
