I do some testing for further learning python.
My setup is an Empty that spawns a cube every 60 tics on a random position. Now what I want is those cubes also get a random color. This is my code for it (attached to the cube on a seperate layer)
def objColor():
obstacle = scene.objects ["obstacle"]
r = random.random()
g = random.random()
b = random.random()
obstacle.color = (r,g,b,True)
What happens is that the first spawned cube gets a random color, but all others that follow don't. I assume that has something to do with blender changing the name of the following cubes to obstacle.001, 002 etc.
But how can I make sure that all the following cubes also get a random color?
Thanks for any help, cheers