Hi,
You can still do the refactoring, you just need to do the VR components as well.
from the constructor you want to move the FP_Gun bits, the FP_MuzzleLocation bits as per Sam’s video. You do however also wawnt to move the motion controller bits, VR_Gun bits and the VR_MuzzleLocation bits. Also move the using motion controllers bool too.
The problem with the BeginPlay is that you need to reference the Mesh1P to activate the correct gun FP or VR. Just create a public function in AGun to either turn on VR or not which accepts the Mesh as a pointer.
void AGun::SetVROrNoVR(USkeletalMeshComponent* Mesh1P)
{
// Show or hide the two versions of the gun based on whether or not we're using motion controllers.
if (bUsingMotionControllers)
{
VR_Gun->SetHiddenInGame(false, true);
Mesh1P->SetHiddenInGame(true, true);
}
else
{
VR_Gun->SetHiddenInGame(true, true);
Mesh1P->SetHiddenInGame(false, true);
}
}
Then just call it from the BeginPlay of the FirstPersonCharacter like this:
Gun = GetWorld()->SpawnActor<AGun>(GunBlueprint);
Gun->AttachToComponent(Mesh1P, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), TEXT("GripPoint"));
Gun->SetVROrNoVR(Mesh1P);
Gun->AnimInstance = Mesh1P->GetAnimInstance();
I hope this helps you out. Unreal 4.16 has very different source due to the inclusion of VR and IWYU, but you should still be able to use what you have learnt up to now to still make it work with that version.
All the best,
Justin