Adding objects with random colors in bge

I’ve made this script yesterday , and I think it may be useful

import bge
import random
sce = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
own = cont.owner
r = random.random()
g = random.random()
b = random.random()
for y in range(-2,2):
    for x in range(-2,2):
        for z in range(-2,2):
            objeto = sce.addObject("Cube","Empty",300)
            objeto.color = [r,g,b,1]
            objeto.worldPosition = [3*x,3*y,3*z]
            print(objeto.worldPosition)    

2 Likes

That is very cool.

Simple, but interesting.