I've read and followed a few posts here but still cannot get my code work.
I was spawning portal actors at runtime, and trying to have each spawned portal display a 2D scene capture. The scene capture component is located at the portal's spawn point. Below is part of my code. What I'm seeing is still the default skin of the static mesh cube, instead of the scene captures. I must have missed something essential. Please enlighten me. Thanks!!
// member of class AQLPortal
// initialize member StaticMeshComponent to a static mesh cube
PortalCamera = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("PortalCamera"));
PortalCamera->bCaptureEveryFrame = true;
PortalRenderTarget = CreateDefaultSubobject<UTextureRenderTarget2D>(TEXT("PortalRenderTarget"));
PortalRenderTarget->AddressX = TA_Wrap;
PortalRenderTarget->AddressY = TA_Wrap;
PortalCamera->TextureTarget = PortalRenderTarget;
// PortalDynamicMaterial = UMaterialInstanceDynamic::Create(BluePortalMaterial, nullptr); does not produce captured scene either
PortalDynamicMaterial = StaticMeshComponent->CreateAndSetMaterialInstanceDynamic(0);
Sep 16 '16 at 03:21 AM
in C++ Programming