procedural generated map is random in editor but not in packaged game
I've created a game that generates a random map using C++ and the rand() functions and some algorithms. I use event beginplay to call my map generator at startup, and blueprints to spawn the assets. This works great in the editor. The level is random every time I play. However, when I package the game, the stand alone game will have the same level every time I launch the game. If I re-package the game I will get a new static map. Please help. I'm at a complete loss with this problem.
asked Jul 25 '14 at 07:11 AM in Packaging & Deployment
I'm just going to answer my own post here in case somebody else runs into this problem. The reason for this behavior is because I did not use a seed for the random number generator. For some weird reason this will still give random numbers when run in the editor, but it will become static when packaged. I added: srand (time(NULL)); to the code and problem was solved.
Thanks to warlord57 for figuring this out.
answered Aug 28 '14 at 11:44 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here