# Randomize the color of an object at spawn.

**URL:** <https://forums.unrealengine.com/t/randomize-the-color-of-an-object-at-spawn/403826>\
**Category:** Rendering\
**Tags:** color-picker, random, unreal-engine, color, UE4, question, CPP\
**Created:** [September 5, 2017, 8:08pm UTC](https://forums.unrealengine.com/t/randomize-the-color-of-an-object-at-spawn/403826 "2017-09-05T20:08:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akiramolas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@akiramolas](https://forums.unrealengine.com/u/akiramolas)\
**Post date:** [September 5, 2017, 8:08pm UTC](https://forums.unrealengine.com/t/randomize-the-color-of-an-object-at-spawn/403826/1 "2017-09-05T20:08:35Z")

</div>

As the title implies, I’m trying to randomize the colors of a certain group of objects every time they spawn, alongside dividing them into groups according to the color they got.

---

<div class="post-metadata">

**Author:** ![Arty-McLabin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arty-mclabin/32/1012076_2.png) [@Arty-McLabin](https://forums.unrealengine.com/u/Arty-McLabin)\
**Post date:** [September 5, 2017, 10:37pm UTC](https://forums.unrealengine.com/t/randomize-the-color-of-an-object-at-spawn/403826/2 "2017-09-05T22:37:39Z")

</div>

1. create a material with some node in it being an RGB color   
2. right click that node and “set as parameter”   
3. create material instance based of that material (right click the material asset, theres an option.)   
4. set the material of your model to use the material instance asset you have just made.   
5. go to construction script, put a node of random color, or a selection from predefined colors you want   
6. material-\>setVectorParameterByName(“your\_color\_parameter\_name\_here”)   

some names above may differ, because i don’t have the engine opened right now. you should figure the alternative names in this case, not that hard.
