Download

Make a rondom linear color and set ti to actor.

Hello guys!

I am trying to create a random linear color in c++, but i dont know how, can someone help me?

Here is moreless what i want to do from BP to c++.
a79e23ec6a5cde104ea7e581e9d4b09339b24b6c.jpeg

I think the alpha (A) needs to be set to 1.0f.

HTH

Lucky for you, there’s already a nice static function for it:



FLinearColor::MakeRandomColor();


Even the comment has ‘Nice’ in the title:

How do I set it to an actor?

Like this?
Actor->SetMaterial(FLinearColor::MakeRandomColor());

You will need to use one of the set “Type” parameter methods, Here is an example:



pMaterialInst->SetScalarParameterValue( FName( TEXT( "EnergyLevel" ) ), energyInterval );


HTH