top of page

Labyrinth's Legacy

Design Documentation

Introduction-

Labyrinth’s Legacy is an adventure survival game where the player starts with nothing, gathering materials, defeating enemies, and acquiring resources. With these resources, players can craft weapons and armor to prepare themselves for the ultimate challenge—defeating the boss.

​

One of the key aspects I learned while working on this game was how to generate a random map for each player, ensuring that no two experiences are the same. This procedural generation makes exploration more dynamic and engaging.

​

Another major feature I developed was the building system. The building mechanics feel smooth, and the snapping system works well, allowing for intuitive and precise construction. These elements combined made this project a great learning experience in both level generation and game mechanics.

Procedural Generation-

LabyrintMapGeberation.png

1. Terrain Generation

  • Defines terrain size (width, height, depth).

  • Uses Perlin Noise to create natural-looking height variations.

  • Ensures terrain edges are uniform to avoid abrupt height differences.

2. Saving & Loading

  • Saves random terrain offsets (offsetX, offsetY) for consistent world regeneration.

  • Saves object placements to preserve the world state.

  • Loads previously saved objects when the scene is reloaded.

3. Object Instantiation

  • Spawns objects dynamically (objectPrefab list).

  • Ensures objects are correctly placed on the terrain surface.

  • Assigns objects to a parent transform for organization.

  • Adjusts physics layers when necessary.

​

This system procedurally generates terrain using Perlin Noise, ensuring a unique but repeatable game world. It also supports saving and loading, allowing the player’s world and placed objects to persist across sessions

Building-

LabyrinthBuild.png
  • 1 Preparing the Object for Placement

    • When crafting is initiated, the system first disables all colliders on the object (craftObject). This ensures that physics interactions won’t interfere while the object is being positioned.

  • 2 Positioning the Object in Front of the Player

    • The object is placed at a fixed distance in front of the player, using the camera’s forward direction.

    • The Y-axis is slightly adjusted to align correctly with the terrain.

  • 3 Checking Placement Validity

    • The system checks if:

      • All panels of the object are touching the ground (using AllPanelsTouchingGround()).

      • The object overlaps with another buildable object (like a wall or floor).

    • If these conditions are met, the object changes to a "valid placement" material.

  • 4 Snapping System 

    • If the object is overlapping another structure and it’s a wall or floor, it will snap to the closest valid position.

  • 5 Confirming Placement

    • If the player clicks the left mouse button (and has the correct tool equipped):

      • Colliders are re-enabled for physics interactions.

      • The game plays a building sound effect.

      • The object is officially placed, and its material is reset.

      • The required crafting materials are removed from the player’s inventory.

      • The object is assigned to the correct layer if necessary.

      • If the object is part of a tutorial step, it progresses to the next tutorial stage.

      • The object is parented to the closest valid structure, ensuring proper attachment.

      • The crafting system resets, allowing the player to craft again.

  • Handling Invalid Placement

    • If the object is not placed correctly, the system changes its material to indicate an invalid placement, preventing the player from placing it.

bottom of page