Hi everyone, i was doing a c++ tutorial …
And once i added a code to my project, i selected the Actor option (wich was told me to do in the tutorial…)
I named it and created it successfuly.
But when i got into visual studio the
is already giving me an error. saying “cannot open source fille”
Also in the same page
class TUTURIALTHIRDPERSON_API APickup : public AActor
The generated_body is also giving me an error saying “Expected an identifier”
That is all the code on the page , i havent done anything on the page yet. Is there any procedure i need to do , or anything ? ty
Just as a heads up:
the generated .H file is created when you build the project, it goes through your .H file and creates a bunch of meta-data things. If your class has any errors or issues, the generated file won’t be constructed. So, you have to fix those issues first in order for the file to be created…
The first thing I would probably look at is creating a publicly accessible constructor. Maybe that’s the issue?
To be more specific, only header tool errors (only interested in the stuff inside UPROPERTY, UCLASS, UFUNCTION, etc.) will prevent generation of the file. Plain compile errors happen after the header generation.
well , looks like i got some bad luck … i followed ur steps, and noticed you copyed both cpp and header files from the guy that was helping you.
So i copyied as well . And still i got errors here is a printscreen
Yeah… so, the problem is that your project is named “TuturialThirdPerson” (which has a misspelling, btw). Mine was called “TutorialCode”.
When I created my project, the “tutorialcode.h” file was pregenerated and included in the project. You probably have a “tuturialThirdPerson.h” file somewhere. You need to change this. You have a few options:
A) Rename the “tuturialthirdperson.h” file to “tutorialcode.h”
B) Change your include to your .H file
C) Create a new project called “TutorialCode” (to perfectly reflect the demo videos and avoid future translation mistakes)
Well, the pregenerated file has:
Which means that it’s including all of the minimal features/capabilites of the engine. Since you aren’t including it, all of the engine capabilities you’re trying to use are unknown to the compiler and you’re getting the funky errors you’re seeing.
You have a line at the top of your code which says: include “TutorialCode.h” and that’s pointing to a file which doesn’t exist. Instead, you can change that to point to your header file by writing: include “TuturialThirdPerson.h” which should exist (based off of the screenshots I saw).
There has been some changes with the introduction of the GENERATED_BODY macro. If you want to follow the tutorial with no hassle, change GENERATED_BODY() to GENERATED_UCLASS_BODY().
Then you will use constructors etc. the old way, like the tutorials.
Without seeing more of your code, I can only assume that this is the cause…
Squiggles (i.e.: IntelliSense errors) are often wrong or out of date. While they are useful when they do work, don’t ever rely on them as actual “errors”. Compile the project and that will tell you if you do have any errors.
In this particular case, a freshly created class will not have a header generated since that happens on a full compile. So “Weapon.generated.h” being underlined is irrelevant until you compile first.