Dear Community,
As usual, I wanted to create a place for people to discuss their findings, questions, and solutions about upgrading to 4.6 !
So if you have any solutions to compile errors, info to share, or questions, feel free to post !
Community participation is highly encouraged!
**#1 ~ Constructor Change**
To avoid lots of deprecation warnings, you should open up every .cpp file in your project and replace the old constructor
```
(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
```
with
```
(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
```
#2 ~ Creating Subobjects
In all of your constructors for every class where you were making subobject components:
replace
PCIP.CreateDefaultSubobject
with
ObjectInitializer.CreateDefaultSubobject
so for example,
UpgradeMesh1 = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("UpgradeMesh1"));
becomes
UpgradeMesh1 = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("UpgradeMesh1"));
Tip: This one is easy to search and replace!
**#3 ~ No more TSubObjectPtr**
Replace all TSubObjectPtrs with regular ptrs
For example
```
UPROPERTY(VisibleDefaultsOnly, Category = "Upgrade Meshes")
**TSubobjectPtr<USkeletalMeshComponent>** UpgradeMesh1;
```
becomes
```
private:
UPROPERTY(VisibleDefaultsOnly, Category = "Upgrade Meshes")
**USkeletalMeshComponent*** UpgradeMesh1;
//restore public context below or put private at the bottom.
//public:
```
**Epic Recommendation: Const Accessor**
Epic also recommends you make this pointer private and create a GetUpgradeMesh1() accessor.
This provides a degree of safety against you losing your core component by changing the pointer to something else, or if someone extends your class and does not understand that this pointer should never be messed with.
```
//.h
public:
USkeletalMeshComponent* GetUpgradeMesh1() const
```
```
//.cpp
USkeletalMeshComponent* AYourClass::GetUpgradeMesh1() const
{
return UpgradeMesh1; //note this function is const
}
```
By making this pointer **const** you prevent people from changing it to point to something else, and causing the Character or other class to lose the ability to find a core component by your established pointer.
See Character.h for examples, at the very bottom. I chose to use FORCEINLINE but Epic is defining in the .cpp.
#4 ~ Mesh to GetMesh()
Replace
YourCharacter->Mesh
with
YourCharacter->GetMesh()
everywhere in your code base!
I recommend doing search and replace for
Mesh->
and replacing it with
GetMesh()->
to avoid replacing the word “Mesh” when it is used in other ways.
**Same for CharacterMovement and all other pre-existing components!
**