Hi all
I am trying to change the base color of a material. Here is the bp
and the error it gives is
I assume it is something related to PieceMeshMaterialDynamic. It is from ChessPiece class.
inside header
UPROPERTY(EditDefaultsOnly, Category = "Chessia")
UStaticMeshComponent * PieceMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Chessia")
UMaterialInstanceDynamic * PieceMeshMaterialDynamic;
and inside source
PieceMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SM_Piece"));
PieceMeshMaterialDynamic = PieceMesh->CreateDynamicMaterialInstance(0, PieceMesh->GetMaterial(0));
Now i don’t know much, and this is my first time doing a material instancing inside c++. I just couldn’t figure out where the problem lies. My best guess is, the problem lies at the line which i initialize PieceMeshMaterialInstance.
How can i solve this problem? Thanks in advance