void AWeaponRailgun::BeginPlay()
{
Super::BeginPlay();
ScopeCam = NewObject<USceneCaptureComponent2D>();
ScopeCam->Activate(false);
ScopeCam->FOVAngle = 10.f;
ScopeCam->AttachTo(SkeletalMeshComponent, FName("ScopeFeed"), EAttachLocation::SnapToTarget);
RenderTarget = NewObject<UTextureRenderTarget2D>();
RenderTarget->SizeX = 1024;
RenderTarget->SizeY = 1024;
UMaterialInstanceDynamic* ScopeMat = UMaterialInstanceDynamic::Create(AssetScopeMat_Default, this);
ScopeCam->TextureTarget = RenderTarget;
ScopeCam->bCaptureEveryFrame = true;
ScopeCam->UpdateContent();
FTextureResource* RenderTex = RenderTarget->CreateResource();
ScopeMat->SetTextureParameterValue(FName("ScopeFeed"), RenderTarget);
SkeletalMeshComponent->SetMaterial(ScopeMatIndex, ScopeMat);
}
It changes the texture from the default, but all I get is gray; not the gray tiles, but solid 0.5 gray. Does anyone have any ideas on why this doesn’t work? I haven’t really been able to find any non-blueprint documentation.