I am on video 4 in the 3rd Person Powerup C++ Tutorial and I am getting errors

I am assuming that it’s an issue carrying over from Video 3 where the changes in recent versions of UE4 make the code in the videos not work, but I haven’t found a solution for them like I did for part 3.

[Here is the video][1]

[Here is Pickup.cpp][2]

[Here is Pickup.h][3]

[Here is BatteryPickup.cpp][4]

[And here is BatteryPickup.h][5]

And below is an image of the errors I am experiencing


I am unsure of what I’m doing wrong/what I need to change/fix

Hi Slateboard

It seem indeed because of a change between 4.5 and 4.7

in pickup.h

delete APickup(const FObjectInitializer& ObjectInitializer);

and change GENERATE_BODY to GENERATE_UCLASS_BODY

that macro changed and it changed the way constructor are handled.

GENERATE_BODY can be used when you want a normal c++ constructor as GENERATE_UCLASS_BODY will be used when you want the objectInitializer.

Cheers,

  • Marc

I will try this. But I have to ask whether or not it’s worth it to continue pursuing this if issues will continue to arise.

I got this - Error 3 error C2084: function ‘ABatteryPickup::ABatteryPickup(const FObjectInitializer &)’ already has a body

And it referrs to this line -

ABatteryPickup::ABatteryPickup(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)

That tutorial series was great back then and I expect you would learn a lot from it too. I don’t think that many issue should occur, outside of this constructor macro if you have to create new classes.

I’d suggest you try to stick with it, post question here in case of trouble and people will be happy to help you.

Yeah, basically GENERATED_BODY is trying to detect if you have declared a constructor. If you don’t, it declares and defines it for you. If you do, then it tries to use it, but expects you to define it also in cpp.

Can you post your BatteryPickup.cpp and BatteryPickup.h after modification, so we can identify the problem?

Here is the BatteryPickup.cpp

Here is BatteryPickup.h

In this case simply change GENERATE_BODY to GENERATE_UCLASS_BODY in BatteryPickup.h

Since GENERATE_BODY did not exist when they made that tutorial series, you can assume you can change every GENERATE_BODY by GENERATE_UCLASS_BODY and remove every constructor declaration and definition except the one in the cpp file with the Object Initializer

Have you been able to resolve this issue ?

I changed GENERATE_BODY to GENERATE_UCLASS_BODY and here is the current set of errors -

I finished the video and built it. No Errors. Thanks!