Changing Colors (Colours) using Kode

By LadylexUK

Changing the color of an object while in a game can be very easy, difficult or impossible depending on the object in question. Objects with more than 3 color channels can be difficult to color the way you would want as some channels cannot be changed while others are linked together so you have to change more of the object than you might want to. A good example of this is the character model, where it is impossible to change the color of clothing without affecting the hair color as well.

WHEN [once] DO [primary color][equals][red]

Primary color = Hair, eyebrows, shirt, pants, shoe leather
Secondary color = Belt buckle, pant stripes, shoe bottoms, hair highlight
Tertiary color = Skin color
Solid color = All

For objects and characters where you need finer control of the color channels your only option is to make a duplicate object with the different color scheme in the same position and toggle visibility.

Randomised colors

For objects that you need to have randomised colors try this:

Put this in a logic cube in your world. Every frame it will create a random color.

WHEN DO [global] [#random color][=][random number][0][to[1]

As you create objects in your world you put this kode

WHEN [once] do [colorvar:mycolor][hue][=][global][#random color]
…WHEN DO [solid color][equals][colorvar:mycolor]

This is good if you are creating a lot of objects over a few frames but if you create all the objects in the same frame they will be the same color. To prevent this you could use the x coordinate of the object and time the color change using it like so:

WHEN [once] DO [#timer][=][x][position]

WHEN [countdown timer][#timer][in frames] DO
…WHEN [once] do [colorvar:mycolor][hue][=][global][#random color]
…WHEN DO [solid color][equals][colorvar:mycolor]


Comments are closed.

Website Powered by

Up ↑

%d bloggers like this: