Intro
This is a tool for UE 5.5 that allows you to generate stacks of physics enabled objects. It was constructed using the PCG framework. This project was originally created for a tech art test over the course of three days
*Tool Documentation Will Follow Below*
Contents
PCG
The tool consists of two PCG Blueprints (one being optional):
– BP_Stack: This is the primary blueprint used for the tool. It contains a PCG component and a collision box. The collision box can be resized and adjusted to any size, and determines the volume that the PCG fills
– BP_StackingSpline (optional): This blueprint contains a spline that can be used to define the area that the PCG will fill
These are located in: Content > PCG
Data Assets
The contents of the stack are determined by a Stack Contents Data Asset. These contain the meshes, their weight, and a random scale range:
– DA_DefaultContents: This is the default data asset that the blueprint will be using when it is placed down. It contains a default cube
– DA_BoxStack: This data asset contains the boxes shown off in the images and video
These are located in: Content > PCG > Data Structures
Editor Utility Widget
There is one Editor Utility Widget to assign in managing the tool:
– EUW_PCG_AssetManager: This EUW has two buttons that allow you to manage the generated assets within the scene. Actors that are spawned seem to remain if PCG is deleted, which is likely just a quirk of how PCG handles spawning non-instanced meshes. This tool will allow you to keep your scene clean of them
This is located in: Content > EditorUtil
Usage
PCG
1.) Drag the BP_Stack into the scene. You should end up with something like this:

2.) Navigate to the right of the screen to adjust the parameters of the Blueprint
3.) The stacks generate within the volume box in the blueprint. The easiest way to adjust the size is by using the scale handles of the BP
4.) To use the spline drag BP_StackingSpline into the scene and enable Use Spline in BP_Stack’s parameters
a.) Keep in mind that points will only generate at the intersection of these two. Meaning that the spline must be within the volume. See image below for example:

Editor Utility Widget
The EUW_PCG_AssetManager is used to handle any un-linked PCG spawned assets. This may occur when you run the PCG Blueprint in your level, and then delete it. The leftover meshes will be unlinked and will have to be deleted. Deleting and then recooking all PCG instances will be the fastest way to clean up the scene outliner.
To do this:
1.) Right click on the EUW in the EditorUtil Folder
2.) Click Run Editor Utility Widget
3.) A window will appear. Click the button that corresponds to the action you want to complete:
Blueprint Parameters
Stack Contents: The data asset containing the meshes that you would like the PCG to use
Disorder: A float value ranging from 0-180. This controls the random rotations of the stacked meshes, along with their placement on the ground. All meshes will be placed in a grid, until the Disorder value exceeds 45, then meshes ground placement will be ‘jumbled’
Use Spline: Toggling this will mean that meshes are only spawned within spline shapes that are intersecting with the volume. See Usage > PCG > Step 4 for additional details
Use Stack Contents as Order: This determines whether or not the order of the stack should be determined based on the order of the Data Asset. Enabling this clamps the stack height to the amount of entries you have in the Data Asset.
Random Stack Count: Enabling this sets the stack height to be a random number within a given range. Unlike the data asset approach, this is not limited to any set amount
Min Stack Count: An integer value used to set the lower bound of the Random Stack Count
Max Stack Count: An integer value used to set the upper bound of the Random Stack Count
Graph Logic
PCG_Stack
The tool is driven by the PCG_Stack asset. Other sub graphs are referenced within this graph. In order this graph does:
1.) Feeds the base points and stack attributes into the subgraph that creates each stack
2.) Generates points within the volume. This can vary based on whether or not a spline is being used
3.) Calculates the maximum mesh bounds and culls points based on the value. This is done so that the generated stacks are less likely to have mesh overlaps
PCG_SG_CreateStack
In order this graph does:
1.) Once points positions are determined, the mesh actor is then spawned
2.) Each base point is fed into the system
3.) A stack count is generated based on the parameters. The logic of this changes based on whether the count is random, or a fixed amount. Each base point is then duplicated corresponding to the stack height
4.) Attributes from the data asset are assigned to each point. This includes mesh path, weight, random scale bounds, mesh bounds, and several other parameters used for simulating physics
5.) Each point is that transformed based on the attributes
6.) Points are then stacked using bounding/position information
PCG_SG_TransformByAttribute
In order this graph does:
1.) Each point is then assigned a random scale and z rotation based on its attributes
2.) Points are inputted individually
3.) A seed is generated from the point to ensure that the transform is random each time
PCG_SG_GetHeight
In order this graph does:
1.) As each point is processed its position is offset by the total height attribute, and its height attribute is added to the total height
2.) Scale are applied to bounds and stored as a height attribute
3.) Each point is inputted, with the first points height initializing the total height variable
Future Improvements
Pivot recentering: As it stands the tool only stacks meshes properly if they have a centered pivot. This mostly comes down to how the height is calculated from the bounds. I did attempt to create a sub-graph that fixed this problem by generating an offset vector, but was unable to implement it into the tool with any success. Generating this vector does become more difficult when factoring in scale and rotation. Ultimately I deemed it too time consuming to pursue, but the attempt can be found in Content > PCG > PCG_SG_PivotOffset
Square bounds: As it stands the tool gets the max mesh footprint to initialize the base points. This is done to limit the amount of mesh overlaps. But as it stands it generates these footprints from the largest min and max bounds of the meshes. This means it isn’t necessarily getting the max XYZ values of the bounds, but rather the max volume of the meshes. Meaning that there could be niche instances where there are still overlaps. This also doesn’t account for rotations, meaning that sometimes meshes may fit within the footprint when oriented, but when rotated, they overlap with another mesh
Mesh Rotations: The only rotation of meshes are within the Z axis currently. I could see a future in which meshes are able to be rotated and re-oriented, and then stacked. Although it would also likely lead to a bunch of un-stable stacks if implemented in its current state
Height cap: The height of the stack is strictly determined by either the amount of meshes in the data asset, or by a random number. This does not account for the height of the volume, and there are instances where the height of the stack exceeds the height of the volume. I think this could be fixed by doing a ‘Cull Points Outside of Actor Bounds’ after the stack is generated. But I ran out of time to do this
Destruction: This is something that I was hoping to do, but frankly just ran out of time for. I did find a good tutorial on how to do this if I had more time
Known Bugs
Unused Actors: I’ve encountered an issue where actors that have been deleted, remain in some sort of weird limbo state. They sometimes reload on startup or when switching a level. I haven’t been able to find out what is causing this problem, but using the provided Editor Utility Widget should clean everything up
PCG Graph Comments: There seems to be a bug in the PCG plugin where graph comments are not saved properly. So if you go into my graphs you may see them un-commented / disorganized.