Change material parameter from c++

I’ve created this material that is a simple texture with clouds. I want that this texture scrolls to X axis.

So I’ve added the Panner “method” that allow the texture to scroll.

Using the parameter “xSpeed” i’m able to control the speed of the scrolling.

I’ve set this material to a sprite.

How can I change the value of the parameter “xSpeed” to control clouds scrolling speed?

You do that via Material Instances:

The functions used in BT examples are also in C++

If you just static movement of texture, just use Panner material node with Time node:

Thanks for your helpful response. But I’m blocked at this point… I have created the material (i’ve inserted the screenshot in the question), now I need create the instance of this materia using editor or using c++? When I’ve the Object of the instance materia how can I set that material into the object UPaperSprite?

Thanks for the help. You has point me to the right direction.

I’ve implemented the class APaperSpriteActor that use the code below in the constructor to load the “dynamic instance material”

UPaperSprite * cloudSpritePtr = ConstructorHelpers::FObjectFinderOptional<UPaperSprite>(TEXT("PaperSprite'/Game/2DSideScroller/Sprites/CloudSprite.CloudSprite'")).Get();

	UMaterialInstanceConstant * cloudMaterialPtr = ConstructorHelpers::FObjectFinderOptional<UMaterialInstanceConstant>(TEXT("MaterialInstanceConstant'/Game/2DSideScroller/Materials/DynamicCloud_Inst.DynamicCloud_Inst'")).Get();
	
	UMaterialInstanceDynamic * dynamicCloudMaterialInstanceDynamic = UMaterialInstanceDynamic::Create(cloudMaterialPtr, GetRenderComponent());
	
	GetRenderComponent()->SetSprite(cloudSpritePtr);
	GetRenderComponent()->SetMaterial(0, dynamicCloudMaterialInstanceDynamic);

Another good reference: