When to create a material dynamic instance when the material has two parameters

Hi!

I’m working with Unreal 5.2.1 and C++.

I have a material instance with two parameters, a scalar and a vector. This is the actor class:


	UFUNCTION(BlueprintImplementableEvent)
	void OnMyScalarChanged();

	UFUNCTION(BlueprintImplementableEvent)
	void OnMyColourChanged();

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(BlueprintReadWrite, Category="Components")
	UStaticMeshComponent* MyMesh;

	void SetMyScalar(double Value);
	void SetMyColour(FLinearColor Colour);



void AMyActor::SetMyScalar(double Value)
{
	MyScalar = Value;

	OnMyScalarChanged();
}


void AMyActor::SetMyColour(FLinearColor colour)
{
	MyColour = colour;

	OnMyColourChanged();
}

I use OnMyColourChanged(); and OnMyScalarChanged(); to create the material instance, but I can’t create two material instances (one on each event).

I think I must have a Blueprint variable with the material instance to set the second value when the first event had created.

But I’m thinking to use one event and throw it when both values are set.

What do you think? How can I create a dynamic material instance when I have to parameters?

Thanks!