Procedural Generation
Author: Najee Jackson
Problem
For this week, I worked on Procedural Generation. It was going well at first until I ran into the issue of loading all the rooms at the start of a level. Due to this, the player started in one room, which led to no other rooms in the level. This heavily hindered the gameplay as the player had only one room of various sizes to explore each time they loaded in.
Solution
I first researched game instances in Unreal Engine 5 to solve this issue. After watching several videos, I used a testing project to see if my theory would work. My initial plan was to use the game instance to load ten rooms connected before the player spawned in. Making the script was pretty straightforward. I made an array of all the rooms that were being used, and if any rooms were created, I added that actor to the array. I then checked to see if that room had any available doors to attach another room to. If it did, I built a room at a randomly selected door; if it didn't, I set a bool called all doors used to true, so it would no longer try to place rooms on those doors. I tested it a couple of times, but I still ran into the same issue of only one room spawning at the start, so I did some debugging and came to the conclusion that the door array that the first room has doesn't get filled until the game begins. To fix this, I moved my script into an actor and placed that into the world. Using this, I was finally able to get ten rooms to spawn at the start that are all connected.
Comments
Post a Comment