Create procedural mesh from animated skeletal mesh?

@SavvySouls @NfrancisJ @Zarrar2802
For us less cpp-ically inclined, I’ll list down the instructions to implement this code.

You will need Visual Studio 2022. You can use this tutorial to install and set up VS2022 for Unreal https://www.youtube.com/watch?v=HQDskHVw1to

We will create a Blueprint Function Library where we will store our code and make it callable anywhere.

Instructions are for UE5 but will work for UE4 too.

These are the steps I took to make it work, some of these might be redundant but I will post them nevertheless for sake of completeness.

  • First we need to ensure Procedural Mesh Component is enabled through Plugins. Restart the editor if prompted.

  • Second, we close the project, and open the .uproject file in notepad and add the plugin’s entry separately too. Normally this happens automatically but I’m not sure if it works for Unreal-provided plugins too so just in case.

  • Save and close the .uproject file and right click the .uproject file, click on “Generate Visual Studio Project Files”.

  • This should create a .sln file of the same name in the same folder as the .uproject file.
    image

  • Now, open the .uproject file again in Unreal Editor and add a C++ class. Note that the method to add a C++ class in UE4 is different, the option is located somewhere else, I don’t remember where, quick google search should fix that.

  • Go to All Classes, search for Blueprint Function Library and select the corresponding class of the same name, click Next.

  • Set Class Type to Public, click on the Private button then click Public again, it adds a “Public” folder to the file path, not sure if that’s important but that’s what I did. Give your shiny new BFL a name and then “Create Class”

  • Now save everything and close the editor, and - Save and right click the .uproject file, click on “Generate Visual Studio Project Files”, just like last time, for good measure. I’m just a guy trying not to break stuff.

  • Now launch your .sln file in Visual Studio 2022.
    image

  • It should launch in VS2022 like this:

  • In the Solution Explorer to the right, locate your shiny new BFL header file under Games/Source/Public/“YOURBFLNAME.h” and the cpp file at Games/Source/Private/“YOURBFLNAME.cpp”

  • Now comes the fun (idkwtfisgoingon) stuff. Copy the above cpp code from Create procedural mesh from animated skeletal mesh? - #11 by mrz_lxa (Thanks @mrz_lxa !) and paste it in the .cpp file at the bottom, after the include lines.

  • Now go up to the include line and under it, add an extra line: include “ProceduralMeshComponent.h”. The goal of this line is to include the Procedural Mesh Component library so that we can use the UProceduralMeshComponent class in our code below. If the previous steps were correct, this should all be clear, otherwise every instance of UProceduralMeshComponent in the below code will be highlighted and give the error " identifier UProceduralMeshComponent is undefined". Try the above steps with the Procedural Mesh Component Plugin again.

  • Add this little snippet to the function name. Note that the BFL name after “U” and before “::” will correspond to your own BFL.

  • Now copy the function name and arguments:

  • Go to the .h file and paste it within the curly braces “{ }” and under “GENERATED_BODY()”

  • Add “UFUNCTION(BlueprintCallable, Category = “Skeletal Mesh”)” above the copied line, Add "static void " before the copied line and add a “;” after the copied line to complete the header definition.

  • That’s about it, I guess. Right click your project name in the Solution Explorer and “Clean” cause why not. Then right click again and “Rebuild”.


  • Hopefully, it should compile. Once it does, launch your project and go to a blueprint graph, RMB and search for “Copy Skeletal Mesh To Procedural” and the node should pop up


  • If you get errors, chatgpt is able to guess fairly well why it happened, ask it.

  • If someone more adept than me at cpp corrects this post, listen to them. I’ll try to update it if I get a chance.