The Summary.
I am declaring then setting the variables, but for some reason the skeletal meshes return null.
Here below I am attaching each skeletal mesh component to a socket and creating default subobjects with each corresponding variable and still no dice. I run the windows debugger and it throws an exception and breakpoint at the skeletal meshes below. When I open the engine thought the class hierarchy has changed and everything is in it’s right place even though that the variable gives a NULL exception. I know that this problem seems unnecessary to resolve but I am trying to resolve this slightly superficial problem before something happens in the future that might affect the functionality of the program itself.
//.h
UPROPERTY(EditAnywhere, Category = "LeftArmSkeleton")
class USkeletalMeshComponent* SkeletonLeftArm;
UPROPERTY(EditAnywhere, Category = "HeadSkeleton")
class USkeletalMeshComponent* SkeletonHead
UPROPERTY(EditAnywhere, Category = "RightArmSkeleton")
class USkeletalMeshComponent* SkeletonRightArm;
UPROPERTY(EditAnywhere, Category = "TorsoSkeleton")
class USkeletalMeshComponent* SkeletonTorso;
UPROPERTY(EditAnywhere, Category = "LeftLegSkeleton"
class USkeletalMeshComponent* SkeletonLeftLegJ
UPROPERTY(EditAnywhere, Category = "RightLegSkeleton")
class USkeletalMeshComponent* SkeletonRightLeg;
//.cpp
ACharacter::ACharacter()
{
PrimaryActorTick.bCanEverTick = true;
Health = 150;
//The Enemy weapon base mesh does not return NULL.
EnemyWeaponBaseMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponBaseMesh"));
EnemyWeaponBaseMesh->AttachToComponent(SkeletonRightArmJill, FAttachmentTransformRules::SnapToTargetIncludingScale, FName("EnemyWeaponBase"));
SkeletonHead = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("HeadSkeleton"));
SkeletonHead->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName("HeadSocket"));
SkeletonLeftArmJill = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("LeftArmSkeleton"));
SkeletonLeftArm->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName("LeftShoulderSocket"));
SkeletoRRightArm->AttachToComponent(GetMesh(),
FAttachmentTransforules::SnapToTargetIncludingScale, FName("RightShoulderSocket"));
SkeletonTorso =CreateDefaultSubobject<USkeletalMeshComponent>(TEXT(TorsoSkeleton"));
EnemyWeaponBaseMesh->SetupAttachment(GetMesh());
SkeletonHead->SetupAttachment(GetMesh());
SkeletonTorso->SetupAttachment(GetMesh());
SkeletonRightLeg = CreateDefaultSubobject<USkeletalMeshComponent(TEXT("RightLegSkeleton"));
SkeletonRightLeg->SetupAttachment(GetMesh());
SkeletonRightLeg->AttachToComponent(GetMesh(),
FAttachmentTransformRules::SnapToTargetIncludingScale, FName("RightUpLegSocket"));
SkeletonLeftLeg = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("LeftLegSkeleton"));
SkeletonLeftLeg->SetupAttachment(GetMesh());
SkeletonLeftLeg ->AttachToComponent(GetMesh(),
FAttachmentTransformRules::SnapToTargetIncludingScale, FName("LeftUpLegSocket"));
}