Hey all. Yep, it’s me, that guy who drops in once in a blue moon when he’s having problems with the game engine and can’t seem to figure them out.
So here’s the deal: I’m trying to control the diffuse color of a material in realtime via a Python script and a couple of game properties. According to the console output, everything is working fine; there are no errors or warnings relating to what I’m trying to do raised. But in the Game Engine, it isn’t working at all. The diffuse color stays statically what it was before starting.
I’ve tried several things, such as disabling Material Caching and using GLSL mode instead of Multitexture, to no avail.
Here’s my script:
from Util import * cont = bge.logic.getCurrentController() own = cont.owner mat = own.meshes.materials print(mat.diffuseColor) if own['intensity'] < 0.001: #No specific intensity set; set according to Type if own['type'] == 0: #Normal, white clouds mat.diffuseColor = (1,1,1) elif own['type'] == 1: #Overcast, gray clouds mat.diffuseColor = (.375,.375,.375) elif own['type'] == 2: #Storm, very dark clouds mat.diffuseColor = (.05,.05,.05) #May add more later else: #Use the specified intensity, for fine control mat.diffuseColor.r = own['intensity'] mat.diffuseColor.g = own['intensity'] mat.diffuseColor.b = own['intensity']
The reason I’m trying to control diffuse color instead of intensity is that it’s a shadeless material, so diffuse intensity has no effect.
Here’s a video; you can see for yourself how it’s not working. https://youtu.be/rzrUQsdVF4k
I don’t know, am I just missing something really obvious here?
Edit: Oh, yeah, maybe I should add that I’m using Blender 2.79, not UPBGE.