Download

Problems with "Introduction to UE4 Programming" tutorial

Hi, I’m having a lot of issues with this tutorial. Not exactly with this tutorial, but with the fact that UE4 on my computer is apparently not working the same way as it is in the tutorial. Apologies if this is the wrong sub-forum, hopefully someone can help here.

Here is a link to the tutorial, in case anyone needs it.

Background: I’m trying to create a project based on the “Code Third Person” template, and trying to create a “Pickup” actor class.

1: The project doesn’t open with VS) I have VS 2013 Express installed. The second video says that, when I create the project, it will open for the first time in VS. This never happens. The project is created successfully, but in order to open it with VS I have to open VS and find the sln on my own, which I think may be related to my next problem.

2: The Pickup class is broken) I create the Pickup actor class exactly as described in video 3. In my newer version of UE I have the option to make the class either public or private. Being a noob, I have no idea what this means yet so I leave it at the default setting (Public). The class is generated-ish and VS is refreshed, and now I’m looking at a Pickup.h file that includes a generated header that doesn’t actually exist. I have no idea where it is, all I know is it’s not there and VS is upset that I’m including a nonexistent file. In my hunt for clues I opened the Pickup.cpp file and found the following code:




#include "MyProject2.h"
#include "Pickup.h"


APickup::APickup(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

}




If VS and I can agree on anything here, we’re agreeing that this is not valid code. Like I said, I have no idea what I’m doing, so I have no idea what this should be or how to fix it.

In a nutshell my problems are: Unreal won’t open VS, the generated header isn’t generating, and the .cpp file is broken.

Thanks!

It’s odd that your project won’t open in VS.
Is the VS project launching if you don’t change anything ?
(If not i would try to reinstall VS and UE)

The code looks just fine and should be compiled without any errors.
Also these generated headers should not make any problems.

And i just want to mention that i was not able to reproduce your erros with UE 4.3.

Okay, thanks. I am using 4.3.

So, to be clear, this should run fine even when there’s no generated header anywhere in the solution?

scr1060982.PNG
As you can see in this image im getting an error when trying
to open the generated header with ctrl+shift+g, but when compiling
i just get one warning about something else.

There are a few steps that happen when you build a UE4 project. First the Unreal Build Tool (UBT) will run. This is a custom step for Unreal. You mostly don’t need to worry about this step. In this case it’ll create the pickup.generated.h file that you can’t find. If you haven’t built the project since adding your new class then this file won’t exist yet.

The next thing that happens is the preprocessor will run. This always happens for C++ code. Anywhere you see lines starting with # are preprocessor commands. UE4 uses the preprocessor for several macros. In your new header file you should see lines saying


UCLASS()

and


GENERATED_UCLASS_BODY()

The preprocessor will replace these with appropriate blocks of code. This saves writing a bunch of boilerplate over and over again.

Finally, the compiler will run using the output from the preprocessor. Your copy of Visual Studio is probably confused right now because it sees a constructor definition for your pickup class but can’t find the declaration. When you build the project, UBT and the preprocessor will provide the declaration for the constructor and it will be part of the code that replaces


GENERATED_UCLASS_BODY()

in your header file.

Don’t be alarmed if VS seems a little confused when you create new classes like in the tutorial. If you want to reassure yourself that it’s working correctly just build the project. If all you’ve done is add one new class it shouldn’t take very long. If the code doesn’t compile for some reason you can search the forums or answerhub. Using the error message to search with will probably help you find an already answered question. If you can’t find anything, feel free to ask. Make sure you include the error messages or people won’t be able to provide very much help.