[Update v0.0.6 A] Procedural Level Generation
Phantom Proxy - Version Number 0.0.6 A - Procedural Update
Hello again! It has been over two months since the last update. Besides working on the game, I was packing, cleaning, and moving to a new city!
Here are the most important updates that came in v0.0.6 (in order of when I completed them):
- Intractable Doors
- Wave based encounters
- Variable height Elevators
- Procedural Corridor Generation
- Level loading progress bar
- Death screen with an exit and replay button
Lets break them all down
Interactables, Doors, and Combat
Interactables are all objects the player can use with the interact key or button. I worked on this first because I knew the player would have to enter a door, which would then need to lock them inside a room.
Once a player opens a door, if they enter a combat space, all doors connected to the room will lock with a skull and chains. Once the player is locked in, they need to fight all the security bots in wave-based combat until all enemies are defeated!
Then, I needed to spice up the decor in the levels, so I made a bunch of props:
To create the waves in the game, I simply make a wave-object and place the enemies I want to be in the wave using normal editor tools.
Once I had the wave system implemented, I worked on 4 simple rooms to be used in random generation: three 2-Door rooms and one small 3-Door room.
For Phantom Proxy's version of procedural levels, all combat spaces will be handcrafted and spawns specifically placed, but the enemies that spawn in those positions will be of random difficulty type (e.g. a soldier with a basic pistol vs. a soldier with a riot shield).
Next, those combat spaces need to be randomly placed in 3D space, and connected by corridors. To attempt this, I started with some basic path-finding in 2D.
The corridors in Phantom Proxy are generated by several passes of a 2D pathing algorithm, and finally one vertical pass to reach rooms that are above or below.
My first attempt was the following 2D system:
Here is the algorithm's flow:
- Essentially, every blueprint will rate each available position by distance to target if it is available (not blocked by a room or wall)
- Then, it will only choose one axis to move on until it is blocked or reaches equality on that axis
- After propagating on that axis until it is done, propagate on the other axis (for example, only x, then only z)
- Finally, if we have still not reached the destination in 2D, use lowest distance algorithm.
- The lowest distance algorithm simply chooses the available point that is closest to the target
- In addition, if a blueprint ever collides with a blueprint in a different corridor, we merge the corridors into one hallway
Next, we traverse the y-axis until we reach the destination in 3D. Finally, we place an elevator.
Elevators are pretty simple, they lift from point A to B. Here are some notes about my elevators:
- If a blueprint has a plane directly above it, this blueprint is marked as an elevator_start
- If a blueprint has a plane directly below it, this blueprint is marked as an elevator_end
- If a blueprint has a plane above and below, this blueprint is marked as elevator_shaft
- An important point to reiterate: since procedural corridors can merge with each other, this allows for elevators to connect multiple hallways to each other and therefore cut down on backtracking
- Then, spawn in the intractable and art assets
- Finally, set the start as point A and the end as point B
There's one more thing you have to know about making elevators: physics. This is the classic problem of how to maintain a players momentum while also making the platform move the player at the same time. You could use friction, you can child the player to the moving platform, or make the player unable to move until the elevator is done lifting.
For my implementation, the scalable solution is to child the player to the platform. This way, I can make horizontal platforms that move in the future! You can see this in action when the red cube turns green when the player walks into the trigger zone. This means the player is now a child of the moving platform.
So we finally get to level generation! We have:
- Rooms that have doors which lock when the player enters, creating a combat phase
- Corridors that connect one door to another
- Elevators that connect a corridor to a door that has vertical offset
There's a lot that goes into level generation, but here are the brief bullets:
- Create a list of rooms we wish to spawn for the current level, then randomize the order
- For every door that is available
- Spawn a room that is offset in the X, Y, and Z axis by a random number of Grid Units
- Randomly rotate the room in increments of 90 degrees
- Add all doors in the new room to the availability list
- Find the closest door to the start door
- Connect the two doors via a Procedural Corridor and remove the doors from the availability list
- Repeat until we have spawned all rooms for the level
- Spawn the end-room
- From the left-over available doors, if they are within a certain maximum distance, connect them together
- Connecting leftover doors will allow the player to avoid backtracking, looping them to either a new area or back to the start
Lastly, I added the above Level Progress Bar, and a Death Screen:
Thanks to everyone who checked the demo out over the weekend and anyone who was interested enough to read all the way through! I believe being open about the development is the better approach to game creation and I'll continue to be open as long (and legally) possible. After this post, I am going to take a couple days break and try and get my developer streams running again. After that, its time for more core mechanics to be implemented into the game! (I'm thinking... looting weapons)
Get PHANTOM PROXY v0.0.7 [LOOT PATCH]
Leave a comment
Log in with itch.io to leave a comment.