(I’m posting this here because I think the blueprint code needs to be written completely in C++).
Hi, I need some help with converting a procedural mesh into a static mesh at runtime, using a blueprint. This is necessary in my game because:
(1) Tile-based terrain height data is read from file to generate vertices, that in turn generate simple skewed 2D planes with fixed X and Y coordinates but variable Z height.
(2) The meshes should be able to be updated at runtime (Height changes by digging etc)
(3) Keeping all the procedural mesh components in the world seems to decrease performance, so they need to be converted to static meshes to indicate they won’t be constantly updated. My plan is: When a chunk should be updated, I’ll destroy the static actor, edit the heightmap data and create the new procedural mesh, which in turn gets turned into a static mesh. The tile map size in view should be at most 50x50 at any time maybe, but even higher would of course be great.
I know the function “Create Static Actor” exists for Procedural meshes as a button if the mesh is placed in the world, but it’s not accessible by blueprints, which is weird, so I can’t access it at runtime. The issue has been brought up several times before and this is often linked as a solution:
However, I can’t get that to work as the code snippet is incomplete and I get errors when trying to complete it. I make my own BlueprintFunctionLibrary class, change the name (UWebEZBPFunctionLibrary) in both the file above and the header to the one I use, but when I start adding #includes to the header file to resolve the “[Something] Not Found” errors, it starts saying there’s Syntax Errors and whatnot in the >UE Engine files<, and even when checking those they seem fine.
I can’t at all figure out what I’m doing wrong, and it feels like touching the C++ code at all whenever importing someone else’s code just wrecks everything, so I’ve had to do most things from scratch in Blueprints so far.
**Can anyone help me with either
(1) Finding a way to use the engine’s existing code to do this task
(2) Getting the linked code to work
(3) Finding a better solution that doesn’t tank performance
Any input is really helpful. Thanks!
Edit: **So it turns out I had shadows enabled for the mesh, and disabling this raised performance considerably! Now map size is probably not an issue, but I’d still like every performance improvement I can get because I want this to be smoothly playable on low-end systems as well. And from a programmer standpoint I am very interested in any more performance settings I can do for these near-static meshes, such as using RuntimeMeshComponent instead (another Plugin I can’t install)