Random colour fed from an array


I’m working on automatic character randomization system and one simple function is just giving me an headache last 2 days. Specifically, random colour fed from an array. Colour is randomly picked from an array and then applied to pattern on the character’s armor/clothing. Issue is that while it works properly most of the time, sometimes it fills pattern with black colour, even despite a fact that array contains 4 colours only, and none of them is black.

I have really no idea what is wrong with this setup. I’ve even used PrintString to see what colour is being used and it shows Red - 0.000, Green - 0.000 Blue 0.000, Alpha 0.000. Sometimes it show that RGBA is 0 even if correct colour is used (not black). Can any of you guys help me please?

That’s probably because of the Length - (-1) operation. So it can come up with an out of bound index. You can get a random array element directly using the “Random Integer” node.


Thanks man, it finally works now. :rolleyes: Just realized I did put there -(-1) instead of -1, stupid me…