Download

Beginer Question

Hey,
i created the file UsableActor.h with rightclick on the folder MyProject.
And now i want to include it into my MyProjectCharacter.cpp with:
#include “UsableActor.h”

But there is the Error:
Fehler 1 error C1083: Datei (Include) kann nicht geöffnet werden: “UsableActor.h”: No such file or directory C:\Users\Chris\Documents\Unreal Projects\MyProject\Source\MyProject\MyProjectCharacter.cpp 6 1 MyProject

Sry parts of it are german.

How could i include this?

When adding files via Visual Studio, I think they go into the Intermediate folder, which means that UE4 won’t find it.
You should either move the new file into the same directory as MyProjectCharacter.cpp, or use the Editor feature to add a new code file which does all of it correctly.

Like this:

Hi ogertot,

As Crafty mentioned above, the preferred method for adding code to a project is through the Editor, by clicking on File → Add Code to Project… This will give you a wizard where you can select what existing class your new class will be derived from, and will automatically create both a .h and .cpp file for you with a basic framework already included in them to get you started creating a new class for UE4.

If you choose to create new files from within Visual Studio, you will need to do what staticvoidlol mentioned and move those files from the default location where VS creates them (using the file path in the error message you quoted it would be \MyProject\Intermediate\ProjectFiles) into your project module folder (\MyProject\Source\MyProject). If you do it this way, you will also have to regenerate your solution in order for the files to be recognized as part of your project and build successfully.

One option I prefer is to specify where Visual Studio will place the newly created file. When you right-click on your project and choose Add New Item, right below where you enter the name of your new file, you will see the location where it will be created. You can change this to show your project module folder, and then the file will be placed in the correct location for you when it is created. You may still have to regenerate the solution for the file to be recognized by the Engine. Note: This option does not appear to be available if you create a new class using the Visual Studio class wizard (in which case you would be better served by adding your new class through the Editor).