What is new syntax of creating sub-objects in 4.7.1?

Hi Guys;

According to release 4.7.1 notes :

•No special constructors needed! Your class constructors no longer need to take an Object Initializer argument.
•Creating sub-objects for Unreal classes now has a new simple syntax.

AESPPawn::AESPPawn(const class FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{

MyCollectionSphere = ObjectInitializer.CreateOptionalDefaultSubobject<USphereComponent>(this, TEXT("MyCollectionSphere"));
}

So, What is the new SYNTAX , please?

Thanks.

MSD.

Hey MSD,

the simpler way is:

AESPPawn::AESPPawn(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
{
    MyCollectionSphere = CreateOptionalDefaultSubobject<USphereComponent>(TEXT("MyCollectionSphere"));
}

Furthermore, if none of base classes of your AESPPawn has a constructor using FObjectInitializer parameter you can declare only constructor without this parameter, which simplifies it even more:

AESPPawn::AESPPawn()
{
    MyCollectionSphere = CreateOptionalDefaultSubobject<USphereComponent>(TEXT("MyCollectionSphere"));
}

We’re gradually removing the need of ObjectInitializers, so you have to check manually if you can remove the parameter from your constructor in this particular case.

Hope this helps!
Mikolaj