Best Practice for creating a new C++ file

Hi, I am once again struggling with the most basic of tasks in UE. I am trying to transition from Blueprints to C++ and running into a lot of confusing issues. I hope someone can clarify it for me.

I am just creating a new C++ file, in the Unreal Editor, using the Add button> New C++ Class.
Previously, I have somehow created subfolders for some C++ files and my project directory looks like

C++ Classes > ProjectName > Public > Folder1

I tried to create a new C++ file in a new folder in a similar matter, however it won’t appear in the UE Editor. I just edited the Path when creating it so that it would be in ProjectName > Public > Folder2 (which i created). (Call this File1)

It does appear in the VS editor, however, I am trying to then create a subclass of it using the same Add C++ file, it doesn’t seem to be able to find it. If I try to create a new file of the same name however, it doesn’t let me because it already exists in the project.

SO this seems extremely confusing for something as simple as creating a new file, I feel like I must be doing something horribly wrong. I can’t really seem to find any simple, clear guides to this. Most forum threads go on about view options and resetting the editor (which I have done).

Nothing has made me feel dumber and more useless as a programmer then trying to learn UE.

Specific questions are :

  1. Is my issue that I created the file in a subfolder? Some forums seem to suggest not to do this? (Then why show a path option at all?)

  2. Is my assumption that C++ files should appear in the editor wrong? (if so, why are some C++ files appearing?)

  3. Is there a guide that can explain what I should be doing here? The UE tutorials always just work properly without any explanation of what could/does go wrong (even though things often go wrong)?

Thanks in advance.

It will appear in Unreal Engine after you will compile the source code.

  1. Nope. Subfolders should work fine.
  2. They will appear after code compilation (If not - try to restart Unreal after that)
  3. Can’t recomend anything, sorry.

Thanks for the quick reply. I am assuming something this simple should be supported, I just can’t get it to work.

I can successfully compile (Compiled in UE and VS) and nothing appears in the editor.


Have you tried to rebuild your project and restart unreal itself afterwards? Hot reload is quite tricky at first.

Yes, I also tried adding some basic classes into the default folder (to ensure it is not the subfolder). They appear in VS (after reload) but can’t seem to get them to appear in the editor (or be searchable for example to create a variable of that type).

Could this be a project config issue? Maybe I created this as a BP project? Should that matter?

Thanks for the insight though.

Try to delete .sln file + binaries & intermidate folders then generate c++ solution:

Then build it in Visual Studio, and then run Unreal.

1 Like

Yup tried that, no dice. Can’t seem to get it to appear in the editor.

In fact, I tried creating a new C++ file that derived from actor an now the whole thing is going crazy.

Try to add “BlueprintType” specifier for UCLASS declaration.

Don’t try to open/edit .generated.h files

1 Like

That fixed the compilation. Thanks. I wasn’t trying to, that is what it was presenting me with upon opening VS.

I appreciate your help on this, I will try later with a new project from scratch, its possible this one was either set up for Blueprints or maybe even upgraded from UE4. It’s helpful to know what I should expect to happen though, even if it isn’t doing it.

1 Like

Ok so I went through the full process, new C++ project, new C++ file in the default folder. My file is appearing in VS but not appearing in UE.

I have tried:

  1. Restart Editor
  2. Delete Intermediate and Binaries folder and .sln file, regenerate project (everything was closed).

It seems like this is unexpected behaviour? Is there a setting in UE I need or something?
Does the file need to be included somewhere first? I am not able to find it to use as a base class when creating new files.

Sorry if this is a dumb question, I am new to C++.
I am using UE5.


did you have checked “show c++ classes” in the content drawer/panel options?

Yes TY for stopping by though

post a screen of the drawer

Ok I think I figured it out. I think it was just because I was creating a class that didn’t inherit from anything. If I extended Pawn, it appears in editor as expected, whether it is in a subfolder or not. When I create a new C++ class that extends none, it doesn’t appear in the editor at all.

I am marking this as closed for now but feel free to chime in if you have more suggestions or explanation about this.

I posted one below, I think I figured it out, thanks for the help

yes, you need a class to extend at least the UObject, else it doesn’t have anything to do with the engine, is just a c++ class

1 Like

This was the missing link, thank you. That makes sense.