How to change an opocity of UNiagaraComponent ?

Hi.
I have an Niagara effect ( it is a looping effect ).
The variable is
UNiagaraComponent* _current_appear_effects;
I may to activate it
_current_appear_effect->SetHiddenInGame(false);
_current_appear_effect->Activate(true);

or to hide it
_current_appear_effect->SetHiddenInGame(true);

I want to hide it smoothly. Smoothly change an opacity of effect from 1 to 0 ( it must hiding smoothly )
how to change the opacity of the effect ?

You can change the opacity of the render material that’s used in the Niagara system, and then destroy/hide the system itself.

Sounds good. But how to do it in C++ ? Would you write an example?

void ACustomer::set_effect_opacity(UNiagaraComponent* niagaracomponent, float opacity)
{

	UMaterialInterface* MaterialInterface = niagaracomponent->GetMaterial(0);

	UMaterialInstanceDynamic* MaterialInstance = Cast<UMaterialInstanceDynamic>(MaterialInterface);

	if (!MaterialInstance)
	{
		MaterialInstance = UMaterialInstanceDynamic::Create(MaterialInterface, niagaracomponent);
		niagaracomponent->SetMaterial(0, MaterialInstance);
	}

	FLinearColor Color	= MaterialInstance->K2_GetVectorParameterValue(TEXT("BaseColor"));
	Color.A				= opacity;

	MaterialInstance->SetVectorParameterValue(TEXT("BaseColor"), Color);
}

this code returns nullptr:

niagaracomponent->GetMaterial(0); 

function set_effect_opacity does not works. the effect become unseen immediately

You have to go the other way around.
Create a float parameter in the Niagara system and use it as the alpha in the particle color. Control the float parameter from the code, don’t try to get the material from the Niagara system.

Update: rather use the float parameter as a multiplier for the alpha that’s already used in the system.