Blueprint Scatter Tool
The books that are scattered around the scene
The scattering tool was a side product of my Wooden Tower scene. Late into developing that environment, I felt that the world was too empty and needed some type of scattered objects in order to populate it. I tried a lot of commonly used plugins made to scatter trash around a map, but none of them gave me the look I was going after, which required more control and precision with the placement of the objects.
The saved books shown in construction script
One thing I knew I liked what when I hand placed all the books into the scene (with duplication it actually did not take that long) and simulate physic on it, they scattered in a much more natural way that you would expect books to behave on shelves. I went around the map shooting the books with the first person character at places where I wanted them to be more spread out. The result was satisfying to me but there was no way for me to save that look, as the moment I exit playmode the books would return back to their previous locations.
In order to save their location, I did my research and eventually came upon Unreal’s save game object, which allowed me to save and read data permanently outside of game sessions
The blueprint responsible for saving object locations and mesh index
So I wrote this little blueprint, which allowed you to tag objects, simulate physics on them, and after you have gone in and shot them around a bit you can save all of their locations and index by pressing F button. The script loops through every mesh that was tagged and saves their transform data into an array, which is then called later in construction script to place them permanently into the scene.
However there was one more problem with this script. I am placing over 6000 books into my scene with it, which caused massive amount of lag and dropped my frame rate by around 20-30. My solution to that was to use Hierarchical Instance Mesh in unreal which allowed me to make only 13 draw calls for all 6000 of the books. This worked very well and made the books have almost no impact on my frame rate at all.
The saved transforms and mesh index are read in the construction script and the meshes are instanced in their corresponding locations.
Later on, I actually used this script again to turn all of the branch cards on my tree into instances, which improved my frame rate by around 10-20. The script by accident had turned into an optimization tool as it was very good at turning duplicated objects in a scene into instances thus reducing the number of draw calls drastically.
leaves have all been instanced by the script, effectively combining them and reduced draw call.
The same script also used out my friend Rodney to place bones into this environment:
A gif showing the placement of the bones (environment created by Rodney)