x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 ( https://wiki.unrealengine.com/Videos/Player?series=PLZlv_N0_O1gb5xvsc7VM7pfoRAKLuIcFi&video=b_vModa3AiM ) 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?

Product Version: UE 4.8
Tags:
more ▼

asked Jul 28 '15 at 04:37 PM in C++ Programming

avatar image

Dante5050
1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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!

more ▼

answered Aug 04 '15 at 12:09 PM

avatar image

Andrii Melnyk
1.9k 60 20 112

avatar image Dante5050 Aug 07 '15 at 06:43 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question