How to add an Actor (or other class) to a plugin?

I have c++ code to recognize yes/no head movements in VR, which I would like to share with the community as a plugin. However, creating a plugin, and adding Actors (or other classes) has been proven very difficult.

The docs probably say everything I need, but they are very sparse.

I’ve read quite a few threads where people suggest to delete folders (e.g., Binaries / Intermediate), and/or “regenerate” the Visual Studio solution (whatever that might involve). I’ve followed many of these “magical” procedures to no avail.

Is there a nice step-by-step explanation of how to create a plugin (using Visual Studio), and how to add e.g. Actors, which can subsequently be used in a Project?

Kind regards

I have the same problem now.I also want to create an actor in plugin C++ code ,and then use this actor to modify such as UV property. now I have no way to solve this problem. And Yes, the ways you said I also have tried.They didn’t work, lol~

This may help you , check my posts here:

hi bitwiseben, maybe some time ago was hard, but really is a very simple task, create a plugin from editor just takes a simple push of the button, if you create a folder structure by hand i afraid you will finish hoverhelmet, but anyway is not super hard.
once you have your plugins you must add a .header and a .cpp
1.- go to your plugin folder
2.- go to source
3.- find private and public folders
4.- create a .txt in private and change .txt for .cpp
5.- create a .txt in public and change to .h (remember same name for both)
6.- now go to your project, right click on the .uproject and generate visual studio project files

now with this you will add a new class for your plugin, open the visual studio .sln and find them

7.- in order to compile you must fill your new class

for header:




#pragma once
#include "Engine.h"
#include "NameOfFile.Generated.h" //in order to use UCLASS for new unreal class is imperative include a Generated.h as final include

UCLASS()
class ANameOfFile : public AActor
{
      GENERATED_BODY()
};



for cpp



#include "YourPluginNamePCH.h" // remember in a plugin for all cpp you must include fist the PCH of the plugin
#include "NameOfFile.h" // now add the header include



this is all, some few steps
i hope this help!

and , thanks for your replies!

, I’ve seen that thread, and studied every reply (including yours) extensively :slight_smile:

, thanks for explaining how to generate Visual Studio project files. At least now I know how to do that :slight_smile:

Unfortunately, I’ve not been able to successfully compile my plugin with actor class by following the steps outlined above. I’ve included a screenshot of my VC solution with outline, errors in output, and .h and .cpp files of my “TestActor” class.

Btw, I’ve put the header file of the class TestActor in a subfolder “Classes”, because that’s recommended in the docs. However, following step 5 (above in ) verbatim does not change anything for me.

I hope that you can spot why I can’t compile my plugin with (child of) actor class. Thanks!

Include engine/core modules in your build.cs file and in your public or private PCH file e.g.

Your header files or PCH:


#include "Core.h"
#include "Engine.h"


build.cs


PublicDependencyModuleNames.AddRange(
				new string]
				{
					"Engine",
					"Core",
...
}

1 Like

@getnamo, that’s it!!

The modules “Engine”, “Core”, and a few others are added automagically when creating a plugin from Unreal editor. I assumed (incorrectly) that I did not have to do anything else to be able to use engine functionality… :slight_smile:

Including “Core.h” and “Engine.h” to my PCH header file did the trick.

Re-reading 's reply, I also see “Engine.h”…

Again, thank you very much. Now all I have to do is keep my promise and finish my plugin :slight_smile:

glad to hear! for future advice remember set your plugin as Runtime in order to package well

Ah, that’s good to know. Thank you!

I just wanted to post that the above reply is a solution to my problem. I only had "Core" as public dependency module name. Adding "Engine" solved it for me.

I thought going through adding C++ classes via the wizard would automatically fix these things for me, I’m afraid it doesn’t.

What I want to ask now is why/when do we add “Engine” and why we only had “Core” in the first place when first creating a blank plugin?