Materials Puzzle

I’m dealing with a little conceptual puzzle and wondered if someone could help.

Lets say I have a box object that I spawn four times so in game I am looking at four boxes

(See attached blend Glowboxes.blend (471 KB))

My one constraint is to use only one box object.

As part of the game play I would want to be able to mouse over a box and have it glow.

My first thought was to set the material emit property to 1.0 in python for that instance of the object but since all of the objects reference the same material all of the objects glow.

I know I could probably substitute the one box with a new object referencing a different material but remember I am constrained to using only one box object that I spawn multiple times. (the box is actually 100,000 verticies and it should glow in several different colors so this constraint reduces the games file size)

I’m curious if anyone has any thoughts or solutions.

The easiest way would be to use object color. While it’s a fairly limited approach and requires the object be lit by an external light, it is easy to use and setup.

if sens.positive:
    object.color = (1.0, 1.0, 1.0, 1.0)
    object.color = (.5, .5, .5, 1.0)

Just make sure you have Object Color enabled in the material options.

A more robust and versatile solution would be to use either glsl shaders or node materials, but these would be much more complex to setup.

Why not play an material action?

Monster, I don’t know how to animate the material and only affect one cube (i.e. one instance) and not the others. I’d be very interested if I am missing something.

Mobius, I think this leads to a solution.

I use object.color a lot and I’m familiar with the implementation.

My sample was actually over simplified. A better example of my question would have used a different material for one of the faces and turned “use object color” on for that material only. OR - because I intend to use object.color to give some ‘in-game’ variety to the basic cube, I could separate that one face into a distinct object and use object.color dynamically only for that one plane (i.e. face) while using it statically for the other five.