ChunMook-Kim / Project_IK

UE5 3D Game Project
MIT License
2 stars 0 forks source link

Procedural Map Generation System #37

Open IDokan opened 3 weeks ago

IDokan commented 3 weeks ago

Procedural Map Generation System in UE5.4 (Similar to Slay the Spire)

Description
Implement a procedurally generated map system in Unreal Engine 5.4 using C++. The map should resemble the structure of Slay the Spire and feature an entry node, final node, and multiple middle nodes, allowing players to choose paths. The system will generate layers of nodes with randomized connections, ensuring a path from the entry to the final node with a boss encounter.


Requirements

Map Layout

Generation Process

  1. Starting Node: Randomly select two distinct rooms (nodes) on the first floor as starting locations, providing players with multiple path options.
  2. Layer Connections: Nodes on each floor connect to the next floor. Each node has paths to up to three closest nodes on the floor above. This process is repeated across six floors, adding variety and choice for players.
  3. Rule for Starting Nodes: Ensure the two nodes selected on the first floor are distinct, preventing duplicate starting points and ensuring variety.
  4. Pathfinding Check: Validate that a path exists from the entry node to the final boss node. If no path exists, regenerate or add fallback connections.

Optimization and Debugging


Reference

Link to Slay the Spire Map Generation Example


Tasks

IDokan commented 2 weeks ago

I was suspicious of performance calling FSlateDrawElement::MakeLines in UMapWidget::NativePaint(), because calling draw call a lot causes severe performance issues.

As far as I investigated it, I conclude it is safe to use in reasonable loops. I attached below research.

A loop through path_points_num caused 0.007ms. A loop through path_points_num * 1000 caused 2ms.

IDokan commented 2 weeks ago

In C++, need to override NativePaint instead of OnPaint function to draw a shape in Widget space. Because OnPaint is a function for Blueprint, OnPaint is not able to override in C++.

In order to modify drawing order using above approach, should handle multiple widgets. Layer modification is not helpful on the issue.

IDokan commented 6 days ago

Pause this task for a while until we are ready to implement Event level, Boss level, and Shop level or such things...