Actor code incorrectly generated in version 4.6.0

This is by design. They refactored the macros and constructors for 4.6. GENERATED_BODY is replacing GENERATED_UCLASS_BODY, so it shouldn’t generate a compile error by using it instead, and in fact using GENERATED_UCLASS_BODY should generate a deprecated warning as it will be removed in 4.7 (At least thats my understanding from the last twitch stream), unless there are other issues. As for the constructor, my understanding is, you can now define your own constructor, your not tied to using the one with FPostConstructInitializeProperties& PCIP anymore.

Cant really say anything about the UCLASS body macro is in the wrong actors header. Can you elaborate on that some more?

I found this while following the Introduction to UE4 Programming - 3 - Creating the Base Pickup Class tutorial.

In version 4.6.0-2357962 of the editor, when you select File>> “Add code to Project”, and choose Actor, the generated UCLASS body macro in is wrong in the actor’s header file. “GENERATED_BODY()” is generated instead of “GENERATED_UCLASS_BODY()”, which causes compile errors. You have to correct it manually. Also, no constructor is generated in the actor’s .cpp file like in earlier versions.

Hi ,

As mentioned, the differences you have noticed are due to changes coming to code classes in version 4.6 (I believe the tutorial you were watching was created in version 4.2). These changes will be more fully explained in the release notes when version 4.6 is released, but I will try to give you a brief explanation of these changes.

The previous macro, GENERATED_UCLASS_BODY() is being replaced with a new one: GENERATED_BODY(). The new macro does two main things that you will notice. First, a constructor is no longer required for each class. If you don’t need one, you don’t have to have one. If you do need one, you will have to declare it in your header file as you would declare a constructor in a normal C++ class. Second, the macro will leave your class within the private: access specifier. The previous macro had left the class in the public: access specifier, so you will want to be aware of that when declaring variables, components, or functions.

A couple other things you are likely to run into:

  1. Like said, you no longer use FPostConstructInitialize in 4.6. This has been renamed to FObjectInitializer. Other than the name change, it is essentially the same.
  2. Components for Blueprints are no longer declared using TSubobjectPtr. You now simply declare them as a normal pointer. You still have to initialize them as before though, but you will be using the new FObjectInitializer instead of FPostConstructInitialize.

Version 4.6 will be released soon. If you don’t want to wait, I would recommend running through the tutorial using version 4.5.1, where the code should be nearly identical to what is in the tutorial videos. Just keep in mind that the code you will be using in 4.6 will be a little different. We are working out how we will reflect the changes in our tutorials.