Paper 2D C++: Cannot Open Source PaperCharacter.generated.h

So I’ve been trying to mess around with paper 2D, just to get some experience with it, and I have run into several problems trying to write gameplay in C++ using the plugin.

At first I ran into trouble with VS not recognizing “#include PaperCharacter.h”, however, I quickly fixed this by adding the “Paper2D” module to my project.Build.cs file, and updating my VS include search path (Right Click on Your VS Project Name->Properties->NMake->Include Search Path) (I included the paths of Paper2D Classes: C:\Program Files\Unreal Engine\4.6\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes and C:\Program Files\Unreal Engine\4.6\Engine\Plugins\2D\Paper2D\Source\Paper2D\Public)

My VS now recognizes the PaperCharacter header, and all of the Paper2D Classes are listed under my external dependencies, but I am having a problem building my project still. It appears that VS cannot open the PaperCharacter.generated.h (found in PaperCharacter.h as “#include PaperCharacter.generated.h” ) source file (as noted in error 6-bolded below). I believe that this is causing the majority of my other errors, but I don’t understand why VS cannot seem to load this generated header.

I presently have one class (one header and one source file) called RPGCharacter which extendes APaperCharacter.
There is currently no code in this source or header file.

My errors are shown below. Any help in resolving this issue would be greatly appreciated.

Errors:
1 IntelliSense: identifier “FWindSourceSceneProxy” is undefined c:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\Engine\Classes\Components\WindDirectionalSourceComponent.h 20 2 RPG
2 IntelliSense: identifier “FOnSelectedLevelsChangedEvent” is undefined c:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\Engine\Classes\Engine\World.h 1929 2 RPG
3 IntelliSense: no instance of constructor “FReadSurfaceDataFlags::FReadSurfaceDataFlags” matches the argument list c:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\Engine\Public\UnrealClient.h 55 92 RPG
4 IntelliSense: no instance of constructor “FReadSurfaceDataFlags::FReadSurfaceDataFlags” matches the argument list c:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\Engine\Public\UnrealClient.h 63 87 RPG
5 IntelliSense: identifier “FMeshBatchElement” is undefined c:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\ShaderCore\Public\VertexFactory.h 488 131 RPG
6 IntelliSense: cannot open source file “PaperCharacter.generated.h” c:\Program Files\Unreal Engine\4.6\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperCharacter.h 5 1 RPG
7 IntelliSense: expected a ‘;’ c:\Program Files\Unreal Engine\4.6\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperCharacter.h 10 35 RPG
8 IntelliSense: a type qualifier is not allowed on a nonmember function c:\Program Files\Unreal Engine\4.6\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperCharacter.h 26 57 RPG
9 IntelliSense: expected a declaration c:\Program Files\Unreal Engine\4.6\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperCharacter.h 27 1 RPG
10 IntelliSense: “Super” is not a nonstatic data member or base class of class “ARPGCharacter” c:\Users\ \Documents\Unreal Projects\RPG\Source\RPG\RPGCharacter.cpp 8 4 RPG
11 IntelliSense: not a class or struct name c:\Users\ \Documents\Unreal Projects\RPG\Source\RPG\RPGCharacter.h 13 38 RPG
12 IntelliSense: variable “APaperCharacter” is not a type name c:\Users\ \Documents\Unreal Projects\RPG\Source\RPG\RPGCharacter.h 15 2 RPG

Hi,

You have to include D:\Program Files\Epic Games\4.7\Engine\Intermediate\Build\Win64\Inc\Plugins\Paper2D

Be sure to add “Paper2D” to PublicDependencyModuleNames in your build.cs file!

Better late then never!

Cheers,
Oskar

Are you sure this is correct? The error expects PaperCharacter.h, but this folder only has PaperCharacter.generated.h. I noticed another folder does have PaperCharacter.h but it doesn’t seem correct to include it. C:\Program Files\Unreal Engine\4.7\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes

I just add PublicDependencyModuleNames.Add("Paper2D"); in mybuld.cs file,where you construct your class.

instead of include search path,you may try this way!

Step 1 is adding “Paper2D” to your Public Dependency Modules in the Yourgame.Build.cs file like this (do not forget to save the changed file before step 2:

PublicDependencyModuleNames.AddRange(
             new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Paper2D" });

Step 2 is regenerating the Visual Studio project files to get access to the Paper2D headers and allow linking, with one of these two methods:

  • In your game’s UE4 Editor under File > Refresh Visual Studio Project
  • In the project folder, right click YourGame.uproject and select Generate Visual Studio Project Files

Step 3 is including the required Paper2D header files and start using the classes, even auto cpmplete of the header file names should work now:

#include "PaperFlipbookComponent.h"

Have fun!

3 Likes

Thank you so much - THIS IS THE REAL DEAL GUY. Note, step 2 is very important - didn’t work for me till I rebuilt all binaries.

I was missing step 2 and it drove me crazy!!!

Thanks. Note that I didn’t need to regenerate the Visual Studio Project Files as the Visual Studio (2017) asked to Reload the file, and it works just fine.