After refactoring I’m getting an Access Violation error when I call SetHand here.
void AVRCharacter::BeginPlay()
{
Super::BeginPlay();
if (BlinkerMaterialBase == nullptr) return;
BlinkerDynamicMaterialInstance = UMaterialInstanceDynamic::Create(BlinkerMaterialBase, this, TEXT("BlinkerMaterialBase"));
PostProcessComponent->AddOrUpdateBlendable(BlinkerDynamicMaterialInstance);
LeftController = GetWorld()->SpawnActor<AHandController>(HandControllerClass);
if (LeftController == nullptr || VRRoot == nullptr || this == nullptr) return;
LeftController->SetOwner(this);
LeftController->AttachToComponent(VRRoot, FAttachmentTransformRules::KeepRelativeTransform);
LeftController->SetHand(EControllerHand::Left);
RightController = GetWorld()->SpawnActor<AHandController>(HandControllerClass);
if (RightController == nullptr || VRRoot == nullptr || this == nullptr) return;
RightController->SetOwner(this);
RightController->AttachToComponent(VRRoot, FAttachmentTransformRules::KeepRelativeTransform);
RightController->SetHand(EControllerHand::Right);
}