I noticed while editing some of Luos’ caves that each section had 2 sockets, 0 and 1. I also know that it is possible to procedurally generate levels using instanced static meshes. It is also possible to attach a static mesh’s socket to another mesh’s socket.
Therefore, logic would dictate that it would be possible to generate a complex maze using the cave system. Would anyone like to enlighten us on where to research such a beast?
-------------- Update 1 -----------------
Pretty simplistic logic:
Random dungeon logic
Give each mesh an index using an array (TileName)
Differentiate between rooms and hallways (TileTypeRoom, TileTypeHallway, TileTypeSeam, TileTypeCap)
Get each actor bounds and set it to an index (TileSizeX, TileSizeY, TileSizeZ)
Get a random Room tile and place at world origin
Give each socket in that mesh an index using an array (TileStartSockets)
At a random socket, place an End Cap transition
Remove that socket from the array
At a random location in this room, add a player start
For each socket in the room:
- Get a random hallway, give each socket an index (TileTempSockets)
- Place the first socket on the room socket
- Add a seam
- Remove the socket indexes of the hallway and room from their arrays
- Loop through each socket, adding either a hallway or a room
- Check each mesh, if that mesh’s bounds intersect another meshes bounds, then try another
- The dungeon size will be how many rooms are added – 1 (the entrance) (DungeonSize)
- When the room size has been met, then go through each hallway and room socket and cap it + seam it
-------------- Update 2 -----------------
Created 5 arrays: Rooms, Hallways, Seams, Caps, Sockets
Created 3 functions: Generate random room, Find Socket Info, Generate Random Hallway
-------------- Update 3 -----------------
Ran into issues with removing items from the array… and it’s almost 04:00 in the morning… so here’s what I have gotten thus far:
Added all of the I, L, T, X, Caps, and Seams to their own arrays
-------------- Update 4 -----------------
Decided to take everything out of the functions for troubleshooting. Ended up being a Set that wasn’t included. Yay. Sort of fixed, except for Initial seed value of 512 will only spawn 1 room, nothing else
-------------- Update 5 -----------------
So I re-did most/all of the functions for readability and code optimization. If you use a set of blueprints consistently, they should be set to a Blueprint function. So I did that. And what do you know… the system is broken, again. Triple checked everything in the functions versus what was working outside of functions, and everything is the same. Length tests through the array shows the length of the array being changed, however, the remove doesn’t remove the socket name that was used (or the socket name I’m feeding into the Remove Name). /sigh.
Of course, troubleshooting / debugging this is a nightmare since ALL VARIABLES ARE NOT IN SCOPE… I really hope Epic fixes this, which I’m wondering if that is why this bloody thing isn’t working.
-------------- Update 6 -----------------
I went ahead and completed the entire logic for the blueprint, even if the Name arrays aren’t being changed as they should be. I am doing a “sanity” check to test for collisions, if the instanced mesh collides with another mesh, then remove it, and put in a cap instead. To handle this, I thought of using bounds and vectors, however, it seems that this was a mistake, as all of the entries in the array are 0,0,0 instead of world coordinate space, so… yea. I might need to do something with GetWorldPosition instead.
Why can’t there be a sane collision test “Does this overlap something else” :\
-------------- Update 7: Major Change -----------------
Small update… I decided to delete everything and start over. Its pretty remarkable at how optimized the code is now (for what it can be) now that I sort of know what I’m doing
I am trying to investigate a way to use 3 separate blueprints (1 for each mesh “type”), a blueprint function library, and a “System Builder” blueprint to put everything together. No idea how to do that, but I’m sure I’ll find a way.
There are a few ways to do this. Since all of the pivot points are at the socket named “Socket”, and I’m trying an iterative approach to level building. Choices choices.
-------------- Update 8: Blueprint tweaking -----------------
Instead of adding transition caps to every socket on the hallway (I got it to work!), I simplified the blueprint to only add a transition cap to the pivot point socket, “Socket”. I’m also looking at using Hierarchical Instanced Static Meshes instead of Static Mesh or Instanced Static Meshes. I should see a huge performance increase using this rather than the other two, or at least I hope!