How could I make a procedural mesh system in Unreal engine 5 so I could warp shapes like ground into pillars and take away space from the ground, like Fullmetal Alchemist Brotherhood
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Creating a procedural mesh system in Unreal Engine 5 that can warp shapes like ground into pillars and manipulate space dynamically (similar to the alchemy effects in Fullmetal Alchemist Brotherhood) is a complex but very rewarding task. Here's a high-level overview and some detailed steps to get you started:
Concept Overview
You want to:
Start with a base mesh (e.g., ground plane).
Procedurally deform parts of this mesh into pillars or other shapes.
Dynamically "take away" or move space from the ground to create these shapes.
Possibly animate or control this deformation in real-time.
Step 1: Understand Procedural Mesh Basics in UE5
Unreal Engine 5 provides a Procedural Mesh Component that allows you to create and modify meshes at runtime by specifying vertices, triangles, normals, UVs, etc.
ProceduralMeshComponent: This is your main tool.
You can generate a grid mesh (like a ground plane) by defining vertices in a grid pattern.
You can then manipulate vertex positions to create deformations.
Step 2: Create a Base Ground Mesh Procedurally
Create a new Actor Blueprint or C++ class.
Add a ProceduralMeshComponent.
Generate a flat grid mesh:
Define vertices in a grid (e.g., 100x100 vertices).
Define triangles connecting these vertices.
Set normals and UVs.
Example (pseudo-code):
cpp
TArray<FVector> Vertices;
TArray<int32> Triangles;
TArray<FVector> Normals;
TArray<FVector2D> UVs;
// Create grid vertices
for (int y = 0; y <= GridSizeY; y++) {
for (int x = 0; x <= GridSizeX; x++) {
Vertices.Add(FVector(x * GridSpacing, y * GridSpacing, 0));
UVs.Add(FVector2D(x / (float)GridSizeX, y / (float)GridSizeY));
}
}
// Create triangles
for (int y = 0; y < GridSizeY; y++) {
for (int x = 0; x < GridSizeX; x++) {
int i = y * (GridSizeX + 1) + x;
Triangles.Add(i);
Triangles.Add(i + GridSizeX + 1);
Triangles.Add(i + 1);
Triangles.Add(i + 1);
Triangles.Add(i + GridSizeX + 1);
Triangles.Add(i + GridSizeX + 2);
}
}
// Normals can be calculated or set to (0,0,1) initially
Step 3: Implement Vertex Manipulation for Warping
To warp the ground into pillars:
Identify the vertices in the area you want to raise into a pillar.
Move those vertices upward along the Z-axis.
Optionally, move surrounding vertices inward to simulate "taking away" space.
Example approach:
Define a pillar center and radius.
For each vertex, calculate distance to pillar center.
If within radius, raise vertex height based on distance (e.g., a smooth falloff).
For vertices outside the pillar, optionally move them down or inward to simulate space being taken.
Use a timeline or tick function to animate the height over time.
You can also add parameters to control the shape (e.g., pillar height, radius).
For multiple pillars, repeat the process for each pillar center.
Step 5: Optimize and Add Details
Recalculate normals after deformation for proper lighting.
Add collision updates if needed.
Use materials with vertex displacement or tessellation for smoother visuals.
Consider using Runtime Virtual Textures or Nanite for performance.
Optional: Use a Compute Shader or Niagara for Advanced Effects
For very complex or large-scale deformations, consider:
Using Compute Shaders or GPU-based mesh manipulation.
Using Niagara particle systems to drive vertex displacement.
Using Geometry Shaders or Material Vertex Shaders for procedural displacement.
Summary
Use ProceduralMeshComponent to create a ground mesh.
Manipulate vertices based on distance to pillar centers.
Animate vertex positions to create dynamic pillars.
Update normals and collision.
Optionally enhance with shaders or GPU techniques.
If you want, I can provide a sample Unreal Engine C++ or Blueprint implementation for the procedural mesh generation and deformation! Would you prefer C++ or Blueprint?