This weeks update focuses on creating proper prefabs and laying out levels in code.
All the previous work shown has been manually positioned one piece at a time.
So now its time to start putting things together in a more formalized way that can be eventually turned in to a level creation algorithm and level saving / loading serialization.
The first task was to start making the prefabs that would be very specifically sized to allow the layout to occur programmatically . That is to say for instance if I wanted to create a short hallway I could line up 3 'hallway' segments in a row placing them 5 units apart and have a 15 unit long hallway.
So in the first screenshot here I have constructed the first hallway prefab and then manually used the type-in values in the editor to place them exactly 5 units apart and as we can see they line up very nicely.
This test turned out nicely and proved that I was ready to try laying this out in code the next evening.
So I created a simple testdungeonroom class in C# the next evening and was able to lay out these hallways programatically seen in the screen shot below.
The next two days I spent working on more code to generate an algorithm to create a dungeon 'room' where I can pass parameters as to how big the room is in a X and Z axis ( its X and Z because Unity is retarded and does things in X/Z axis instead of X/Y axis but when in Rome they say ... )
I actually ran in to one unexpected issue when doing this ; which was the prefabs had all been constructed with the origin point in the bottom left.
When creating the room I used the same corner segement but rotate it 90, 180 or -90 degrees depending on which corner it will go in.
Because the origin point was in the bottom left corner instead of the center it also rotated from that point and caused alignment issues.
I could have accomodated for that in code; but I also found that my first layout was 'too tight' and didn't look right. I am able to adjust the camera FOV but even so it just didn't look right.
So I took an extra evening and tore the prefabs apart, made them bigger and re-centered the origin point to be the center of the prefab.
Finally we have a shot showing off the result of the weeks work which is 4 prefabs that contain origin in their center along with the first code-generated room!
This can now be used to take the next step in to generating dungeons.
I would like to potentially have randomly generated dungeons for replay value but I do feel static dungeons allow for a much better constructed story and plot.
I need to give more thought to how I want to proceed with all this and what is the best direction for the over-all game but for right now while in alpha prototype mode this gives me a baseline tool for getting a prototype dungeon in place and start building in more features in the next week.
No comments:
Post a Comment