How do I use UProceduralMeshComponent? (can't #include)

I want to add a Procedural Mesh Component to my Actor, but I don’t seem to be able to #include it. What do I include to make the C++ code recognize UProceduralMeshComponent?

I did see
this suggestion, using a blueprint to do the actual component adding, but that has not worked out well for me. Every time I restart my project, the blueprint forgets it has a ProceduralMeshComponent, and I have to add it again.

I think I may have solved it. By using the component in the blueprint, I was able to locate the class in the content browser. From there, I could create a derived C++ class, which was fully usable without any compiler errors.

1 Like

I was having the same problem so tried resolving it as you did, by creating and using a subclass of UProceduralMeshComponent, which does the job. I noticed that the header file generated by the editor contains an #include for the component, so I tried copying it into the header for the actor and while VS complains, it does compile! No dummy class needed.

Add the following to your Actor’s header file:

#include "ProceduralMeshComponent.h"

While Visual Studio will complain about not being able to open the source file, it should compile just fine.

Why the same is not working for me? I wrote #include “ProceduralMeshComponent.h” but code is not compiling with it, also this header file is on Plugins folder of Engine, so probably there is another way to set up this plugin?

This doesn’t work for me. My compile fails because “Error C1083: Cannot open include file: 'ProceduralMeshComponent.h” : No such file or directory"

I’m using 4.9, why is it working for you but not for me?

A dependency to the ProceduralMeshComponent module is required in one’s ModuleRules build file. For example:

MyGame.Build.cs

public class MyGame : ModuleRules
{
    public MyGame(TargetInfo Target)
    {
        PrivateDependencyModuleNames.AddRange(new string[] {"ProceduralMeshComponent"});
    }
}

One can then include ProceduralMeshComponent.h in C++ code:

#include "ProceduralMeshComponent.h"

Anyways, that’s what worked for me.

i followed timtimmy above & i was finally able to get simplecylinderactor code on this page to work in 4.9 Generate Procedural Mesh - C++ - Unreal Engine Forums

I’ve created an extremely simple example of using UProceduralMeshComponent purely in C++. You can view it here:

Apparently, what happens is that once you create a derived class, “ProceduralMeshComponent” automatically gets added to the “AdditionalDependencies” section of the .uproject file, thus allowing the header to be freely included anywhere after that.

hello ,have you resolve this question? could you tell me? i am very thanks for you.

Follow this tutorial: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

Sometimes this happens. Watch out !

1>WARNING : warning : Plugin ‘xxxxx’ does not list plugin ‘ProceduralMeshComponent’ as a dependency, but module ‘xxxxxx’ depends on ‘ProceduralMeshComponent’.

This happens because you have to add the plugin to your uplugin file, in case you are building a plugin not a project using this other plugin:

 "Modules": [
     {
       "Name": "MyPlugin",
       "Type": "Runtime",
       "LoadingPhase": "Default"
     }
   ],
   "Plugins": [                       // <--
     {                                // <--
       "Name": "AdditionalPlugin",    // <--
       "Enabled": true                // <--
     }                                // <--
   ]   

For me, using PrivateDependencyModuleNames didn’t work. It works with Public version of the variable instead.