4.7 C++ Transition Guide

Bah, I misunderstood what you wrote… Yeah, that sucks indeed, but the old way with FObjectInitializer still works so you can fall back to that for classes that don’t have the constructor yet.

I was just bitten by DrawDynamicElements being removed from scene proxies. It seems it was deprecated in UE 4.5 and was planned to be removed since then. It’s shame that Epic didn’t add a deprecation warning to those using DrawDynamicElements (to cause compiler warning) in the meantime but it wasn’t too difficult to track down the reason my meshes weren’t being displayed.

It’s a simple enough change to make since the replacement function is very similar but you can see what I had to do at Update to Unreal Engine 4.7 · volumesoffun/cubiquity-for-unreal-engine@2a81df4 · GitHub

I believe that the wiki tutorial on procedural mesh generation will need updating too.

Thanks for sharing Milliams, very important info!

For anyone who is interested, here’s Epic’s 4.7 Release note on this topic:

“GetDynamicMeshElements path on scene proxies is enabled by default
PreRenderView / DrawDynamicElements are no longer used and have been removed”


**Request**

Milliams or someone else who is currently doing dynamic mesh stuff, can you update the Procedural Mesh Generation wiki to 4.7 ?

https://wiki.unrealengine.com/Procedural_Mesh_Generation

I want to make sure a fully rigorous test case is used to verify the new code and I dont have such a test case right now.

Rama

Regarding constructors, it seems there’s no way to replace AYourHud(const FObjectInitializer& ObjectInitializer) and AYourGameMode(const FObjectInitializer& ObjectInitializer) with versions without FObjectInitializer’s.
You must keep them for HUD and GameMode.

I could swear I replaced it in my game mode. Will double check when I’m in the office tomorrow.

I can confirm that with Game Mode and GameState you still need to use an ObjectInitializer.

As kamrann](https://forums.unrealengine.com/member.php?27203-kamrann) said further up, it depends if the inherited class uses GENERATED_BODY or GENERATED_UCLASS_BODY. With GameState and GameMode thats the case. Looking at HUD, I also see GENERATED_UCLASS_BODY so you would still need an ObjectInitializer for that too.

Hi DamirH,
I’ve tried adding Super() to constructor initialization list in 4.7 to the above code in fresh project and I had not reproduced any crash. Is it something that was re-occuring to you? Could you provide more details how to reproduce the crash?

We’d like to investigate, but without repro it’s not possible.

Thanks,

Simply use the normal constructor with the ObjectInitializer. It won’t kill you doing so, and you would save nothing by using the default constructor.

Hey ,

It was recurring, I couldn’t launch the project all, ever. I am not in the office right now so I’ll be able to post code in the morning.

EDIT:

Ok, I can replicate it. Editor loads up to 70% then crashes.

4.7 Class Constructors

Dear DamirH,

Is there a reason you are avoiding the ObjectInitializer constructor?


**4.7 Class Constructors**

For those who might be confused about all this:

You can easily create a constructor in 4.7 using this arrangement:

**.h**


```


UCLASS()
class AYourClass : public AYourSuperClass
{
	GENERATED_BODY()
public: 
	AYourClass(const FObjectInitializer& ObjectInitializer);

};


```



**.cpp**


```


AYourClass::AYourClass(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
   //add your constructor code / other constructor function calls here
}


```



Enjoy!

Rama

Hi,

IOnlineFriends have been changed to add the delegate inside the parameter functions like ReadList…
IChatInterface have been added, so you must implement it in your OSS Class.

I’m still converting my project, but those one were not highlighted in the release notes :smiley:

Thanks,

Blackboard Key Init

Header.h


uint8 enemyKeyID; // no change

Source.cpp




blackboardComp->SetValueAsObject(enemyKeyID, InPawn);

/* becomes */

#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" 
...

blackboardComp->SetValue<UBlackboardKeyType_Object>(enemyKeyID, InPawn);

I don’t really understand why they did this , but now you need to include each file for each type (Object , Float , bool ,…)

Rama,

No reason, I just noted that adding a call to Super() from a default empty constructor makes the editor impossible to launch, that’s all.

“Creating sub-objects for Unreal classes now has a new simple syntax.”

I tried finding some documentation on what this means, but haven’t found any luck. Previously in the constructor I was using as you show it with the FObjectInitializer. In the default constructor now without the initializer, how would you create a sub-object? For now I will stick with the old constructor style but was just curious.

There’s a post in this thread, just do this:

Just replace


ObjectInitializer.CreateDefaultSubobject< Type >(this, Name);

with


CreateDefaultSubobject< Type >(Name);

I think you’re confused with ‘calling’ super like this:


AWaCharacterBase::AWaCharacterBase() : Super()
{
    //constructor code
}


This is what you’re supposed to do, it specifies which version of the superclass constructor should be called just before this constructor is run. If you are just using the superclass default constructor you don’t even need to do : Super(), since it does that by default.

thanks! it was the “this” I wasn’t omitting, was still using the 2 argument overload

That was indeed the case. I was under the impression that the two were equivalent to each other.

Guess this one is gone?

This one too… (among many other IOnlineSession codes)