UPostProcessComponent is null - Unreal VR Dev Section 1-15

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 :slight_smile: my UE version is 4.26.2.

Thank you so much!

I found someone in Udemy Q&A that had the same problem a year ago and the solution was to downgrade UE to 4.24, I tried that but since all the assets are newer the map and bp are no longer working.

You could also try refreshing the blueprint. Sometimes they can cache the wrong value. Right click the blueprint > asset actions > reload.

Hi Sam! I tried reloading the blueprint like you suggested but didn’t work :frowning: