Download

Level generation from template

Hi all. I wanto to ask your opinion of best approach for level generation. What I want to achieve:

  • set loading screen
  • call open level method to load template
  • create/call generator method
  • disable loading screen after load
    So the question is: what unreal class should I use for generator, how better to organize it
    I’ve tryed to use AActor as a parent and spawn generator inside level. It’s not good solution becsuse hard to operate with it. I would like to call static method and that’s all. I’m thinking about creation generator as child of UObject and attach to GameInstance. Would it work?

Additional question: how to subscribe to delegate event just once. I want to unsubscribe inside lambda for example.
Thanks

What is the actual problem?

In general, an AActor that drives procedural generation is pretty good, because it allows you a good spot to store various parameters for the generation. Also, AActors are good places if you want to set up replication (support networking.) You could for example put generation in BeginPlay() in the AActor. Make one AActor instance in your map, and configure it as appropriate. (Your “map” is then your “template”)

Another place to put whatever the “generator method” is could be in the GameMode, or maybe in an overridden UWorld, at least if you use C++.

It all depends on what your currently problem really is.