How do you adjust Material Parameters through code

I have been trying to make text glow on a rock based on the actors proximity. It was pretty easy to mock this up in a blueprint but I am having a hard time implementing this in code.

In my header file I have tried

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "MCParameters")
	class UMaterialParameterCollectionInstance* = Inst;

and in the constructor of my code file I have tried

	Inst = GetWorld()->GetParameterCollectionInstance(LocationCollection);

but I receive an undeclared identifier error. I know that I am receiving this error because I haven’t declared LocationCollection anywhere in code, this is just the name of my Material Parameter Collection asset in Unreal Editor.

What would be the best way to get this set up? I’m pretty sure I know exactly how to implement the SetVectorParameterValue function, just not get all the important information assigned…

Thanks in advance for the help!

It would need to be a UMaterialInstanceDynamic and then you would just use the Set functions. A quick google gives us a nice thread on here showing some code on how to use it

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms