Hello.
I’m stuck at this section (1-15: Dynamic Material Instances), it looks like the UPostProcessComponent I intent to use is always null, I checked the video multiple times and I can’t find what could be the reason for it to be null.
Header file looks like this
UPROPERTY()
class UPostProcessComponent* PostProcessComponent;
CPP file looks like this
AVRCharacter::AVRCharacter()
{
PrimaryActorTick.bCanEverTick = true;
VRRoot = CreateDefaultSubobject<USceneComponent>(TEXT("VRRoot"));
VRRoot->SetupAttachment(GetRootComponent());
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(VRRoot);
DestinationMarker = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("DestinationMarker"));
DestinationMarker->SetupAttachment(GetRootComponent());
PostProcessComponent = CreateDefaultSubobject<UPostProcessComponent>(TEXT("PostProcessComponent"));
PostProcessComponent->SetupAttachment(GetRootComponent());
}
BeginPlay event inside CPP file looks like this:
void AVRCharacter::BeginPlay()
{
Super::BeginPlay();
DestinationMarker->SetVisibility(false);
if(BlinkerMaterialBase != nullptr)
{
BlinkerMaterialInstance = UMaterialInstanceDynamic::Create(BlinkerMaterialBase, this);
if(PostProcessComponent != nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("PostProcess Is not null"));
PostProcessComponent->AddOrUpdateBlendable(BlinkerMaterialInstance);
BlinkerMaterialInstance->SetScalarParameterValue(TEXT("Radius"), 0.2);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Is null"));
}
}
}
Game was crashing without checking if PostProcessComponent was null, everything was working so fine until this point, the post process was working just fine before the dynamic code, the output log looks like this:
LogTemp: Warning: Is null
I would really appreciate any help you can provide my UE version is 4.26.2.
Thank you so much!