I debugged my code and found out that the CreateDynamicMaterialInstance was returning a null value, so I changed my code to this :
void ABatteryCollectorCharacter::PowerChangeEffect()
{
/* Create a dynamic material instance from our mesh's material 0 */
UMaterialInstanceDynamic* DynamicMaterial = UMaterialInstanceDynamic::Create(GetMesh()->GetMaterial(0), this);
/* Change color to yellow */
DynamicMaterial->SetVectorParameterValue("BodyColor", FLinearColor::Yellow);
/* Set the mesh's material to the new one */
GetMesh()->SetMaterial(0, DynamicMaterial);
}
Now this seems to work, the only problem I have now is that when setting back the material (not sure if this is the best way of doing it) it seems to sometimes set it successfully on the first frame. The rest of the time, the character appears gray (the same gray as when the editor is compiling shaders) and flickers a lot when the camera is turning or the character jumping (as if something had trouble keeping up).
Also, while looking to the DynamicMaterial in debug, there seems to be a lot of null values :
Any help appreciated, Thanks !