3rd Person Power-Up Tutorial Coding Issues

So, I’ve been using Unreal’s tutorial videos to help get a better understanding of the program, starting with the Third-Person series. I was at part 5 of instruction ( A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums ) when I ran into some trouble. When I debug the code, it comes back with errors in my ThirdPersonPowerUpCharacter.cpp, which all seem to stem from the line near the top that reads “AThirdPersonPowerUpCharacter::AThirdPersonPowerUpCharacter(const class FPostConstructInitializeProperties& PCIP” followed by “: Super PCIP”. I did change this from what the 4.8 engine has as default code because I had to do something similar for an earlier tutorial to get my game to work, but now it seems that this code is too old for Unreal to recognize. I checked my spelling multiple times and went so far as to paste the source code into my project to ensure there weren’t any errors, but it still wouldn’t run. I am convinced that whatever I replaced in that line of code is needed to run the game properly but I can’t for the life of me remember what it was. How do I fix this? What do I need to change from the source code (found in the link above) to make the game run in 4.8?

Hello, Dante5050

I am sorry to hear about your problem.

Please note that in Unreal Engine 4.8 you should use FObjectInitializer instead of FPostConstructInitializeProperties, so your constructor will look like this:

AThirdPersonPowerUpCharacter::AThirdPersonPowerUpCharacter(const class FObjectInitializer& ObjectInitializer) : Super (ObjectInitializer) {...}

You can also declare constructor without any parameters (however, please pay attention to the Super call):

AThirdPersonPowerUpCharacter();

Another change that should be taken into consideration is the new GENERATED_BODY() macro. The most important thing about it is that you don’t need to declare constructors for your classes anymore (unless you need one).

However, please also pay attention to the fact that with GENERATED_BODY(), class members are private by default (not public, as it was with GENERATED_UCLASS_BODY()).

Thus, to make the game run in 4.8, please make sure that conditions mentioned above are met in your code.

Hope this helped!

Have a great day!

Thank you very much. With these instructions I’ve been able to cut the amount of errors I have down to 8. I made my constructor look like the example you provided, replaced any use of “PCIP” with “ObjectInitializer”, and changed the “GENERATED_BODY()” in my ThirdPersonPowerUpCharacter.h to a “GENERATED_UCLASS_BODY()”, which helped the program find the variables that I suppose were private before that point. The problems that remain are as follows:
" CollectionSphere = ObjectInitializer.CreateDefaultSubobject(this, TEXT(“CollectionSphere”)); " will not accept the = as an “operand”

Various lines relating to the CollectionSphere beyond the line above come back with an error due to being connected to an incomplete class. I assume these will go away once I fix the first problem.

" if (MyGameMode->GetCurrentState() == EThirdPersonPowerUpPlayState::EPlaying) " comes back with errors at “GetCurrentState()” (saying the code for the GameMode has no member for that) and at “EThirdPersonPowerUpPlayState” (saying a name followed by :: has to be a class/namespace name). I figure that the first error here is due to the code in my GameMode cpp and header bearing very little code in them, but because editing the GameMode code wasn’t covered in the tutorial and the 4.8 version has changed the way the way things work, I hesitate to simply copy/paste the 4.4 source code for GameMode that is provided in the tutorial. As for the second error, I am unsure of what to make of it.

Again, thank you very much for your assistance. I hope I can hear back from you soon.