when i call this in the editor via a blutility it all works fine.
but when i try this in the beginplay event it crashes as soon as it tries to acces the MaterialMapkey.
First check if this is a multiplayer game… beginplay will run both server and client… server does not have any render modules, so i guess GetVectorParameter would not run properly…
Second: im not sure about this, but…
i think you should create dynamic material instance before you try get any parameter from material because whatever is the material is an instance of any master thats applied as non dynamic material?!
virtual void BeginPlay() override
{
//create dynamic material anywhere u like, Constructor or anywhere .
UMaterialInstanceDynamic* DynMaterial = UMaterialInstanceDynamic::Create(Material, this);
//set paramater with Set***ParamaterValue
DynMaterial->SetScalarParameterValue("MyParameter", myFloatValue);
MyComponent1->SetMaterial(0, DynMaterial);
MyComponent2->SetMaterial(0, DynMaterial);
//...
}
im not sure you can still get params just from materialinterface if no dynamic material applied to mesh… since material instances creating non runtime readable materials . as i know… maybe im false
yeah obviosly … but why? as i said when i run the same function in editor mode it works just fine.
is there any restriction on accessing materials at runtime? i can’t find any info about this and giving the fact the interface class is under the runtime section it confuses me a little