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