Procedural generation of a track?
I'm currently creating an infinite runner game. At the moment I'm creating it as a campaign, where each level is hand built and the player moves from level to level / level select screen etc.
However, I aim to create an endless mode for replayability.
I know the usual method of infinite runner games the world moves and the character does not, but for this game, I need the character to actually move, since they are being chased - and can be slowed down and caught.
I am using a straight line track, so there is no worry of twists and turns. the game is being made for children, so I'm keeping it as simple as possible.
How can I create a procedurally generated track with the collectibles and obstacles also being procedurally generated on to the track?
Any help would be greatly appreciated.
asked Oct 10 '14 at 03:33 PM in Blueprint Scripting
The Quick Fix:
The fastest way to do it would be to pre-create hundreds of various track sections as a blueprint and use a class to spawn these random sections into the world.
The Proper Fix:
Other wise unfortunately what you are asking for is not a straight forward answer, but it can be done. The good news is your parameters for this make things easy (easier):
What I would do:
You are going in a straight line, which means you really only have to worry about your progression along one axis, we'll say Y as the "forward" axis. X is left and right, while Z is jumping. which means once you move along the Y axis by a certain amount you can spawn the next section. Then you can build a blueprint for a track with exposed variables for tweaking the rewards and difficulty. It would utilize a spawning volume or volumes that randomly generates random coordinates within the volumn and on the track to spawn the obstacles and collectibles randomly. You'll have to track what is spawned when generating the new track so things don't overlap improperly. Probably need to spawn obstacles first then collectibles and check if an obstacle is present.
The creation of the spawning volumn(s) would be similar to what is done in the UE4 C++ tutorials.
It may be efficient to "spawn" using another thread if possible (haven't looked much into UE4 multi-threading but I'm pretty sure it exists). Also garbage collection; if you are building an infinite level eventually you will have 100 miles of stuff behind you. If your game does not go backwards make sure you remove anything behind you, other wise you'll have to use some occlusion volumes (think that's what they are called) to stop the engine from working on things that are not visible... UE4 may handle this automatically be be mindful of it if you find your game slowing down.
One very important thing to remember, I believe UE4 does infact have a maximum world size... so if you keep running forever in the Y direction you may find your self hitting the end of the virtual space... not sure how big it is but it is pretty big.
Hope this helps
Follow this question
Once you sign in you will be able to subscribe for any updates here