Dynamic data in components (Color)

Hello everyone

At first, im new in C++ and Unreal.

I have a code which it changes de color randomly of a mesh. I know that i can solve it using FLinearColor::MakeRandomColor.

This code runs in a ‘onHit’ function.

My question is: ¿Why i cant use C++ functions like rand?

In a future, I’ll connect with data transfered by a script made in Python. The data will contain the color of my materials. I think I’ll get the same problem because is dynamic data.

Thanks so much,

Make sure you create a UMaterialInstanceDynamic first (in Begin Play as Example) and assign it to the Mesh. After that you can set Material Parameters as you like. FLinearColor::MakeRandomColor() or FColor::MakeRandomColor() work as expected.

Here some Docs about Dynamic Materials