Color Change In-Game? (& more questions)

So, I have this Character Creator. I want to make the object change color when I click on a button in the HUD. This works like a charm when I make it all in a new project, but although the settings are almost exactly the same in my game, it somehow doesn’t work. The material color changes in the properties panel, but not on-screen (neither in the 3D view nor in-game).
Does anybody know what could be the problem?

I also have three more questions:

  1. Is there any other possibility to change the color in-game?

  2. Is there any possibility to make a “color slider” in the HUD?

  3. If I have 3 different body types for a character, for example, what would be the best way to switch between them in-game? Right now, I’m using the replace mesh actuator. But because it also changes the material (Which is actually good, just not for this), I’d have to make the color change action/actuator for every body type. If you know any solution, please tell me.

PS: I have no experience with Python, so if I need a script, I’d need help…
Thanks in advance. I’m probably asking simple and silly questions, but I haven’t found anything on that topic. ^^

here’s a quick blend for no. 1 & 2 question. hope this helps.
for the third one. i think there’s no easy way. you need to either learn shape keys or just stick to your method.

Attachments

color changer.blend (479 KB)

Thank you!

Oh, I haven’t even thought about using shape keys. Right now, that seems like the best method, haha. Thanks again!
Just one more question. If I add or remove vertices in a shape key, will it still work?

No it would not reapply vertices that has beeen deleted. Oh i forgot to mention
i found a good template for your 3rd question. It’s name is unihuman- made by rorkimaru, i think?
It uses shape keys to change the body of the character. And you can change gender of the character.
Sorry for mistyped text, im using a cp.

For this script to work in GLSL mode, enable Object Color in Material tab.

Yep, I’ve already tried it, but it doesn’t work in the game engine, does it?

I tried it, but it still doesn’t work. Somehow, the color only “updates” when I change a setting (specular light, shadeless, whatever; it doesn’t update automatically with the timeline) :confused:

Unihuman can be used in bge but you should animate the keys and control it via logic bri ks or python.

Raco is right. Enable glsl then tick the ‘use ob color’ in materials tab.

i tried to solve the problem with scripting, but still, it only works as soon as I quit the game and go back to the 3D view. I have no idea why this is happening, because I already enabled GLSL, ticked the object color and so on. :confused:

Monster is right ^^

Lol Monster how many times have you posted that image? :smiley:

Never seems to be enough though.

Thanks, that was certainly helpful. (I will not use BPY within the Blender Game Engine. xD)
Sorry if I ask dumb questions that have probably been answered a million times before. Must be my poor researching skills.

Now I have some more dumb questions and then I will hopefully understand how to do it :smiley:

  1. How can I script without the bpy, if I’m not supposed to use it? Or should I only use logic bricks?
  2. (I actually meant the material color, not the object color) It just won’t animate, neither with actions nor with Python. What could be the problem?

As far as I know there’s no way to change the material color in the bge, except for replacing the mesh.

However, I think there’s another way by using the bge.texture module since textures can be modified in game. A dynamic texture could be created by a list of color values for every pixel, or you could load an image into such a list. The same technique could be used for diffuse as well as for specularity and alpha.

It all depends of what you need for your game though. You only have to change color? Why not use object color, since it’s easy in use? Just don’t forget to set the material color to white so the full spectrum of the object color can be used.

In some near future I’ll try to illustrate this technique with car crashing. Instead of replacing the mesh of the car with a predefined crash model I think it would be nice to have dynamic bumps and scratches, using the same mesh, but by deforming it and ‘painting’ dynamically on the texture channels (diffuse, specularity).

Sweet, thanks. I finally got the object color to work =D

  1. You can use the standalone or the Game Engine Python modules.
  2. You can’t change the material color, as Raco said. You can change the vertex color of the mesh using Python, though.

Thank you, that was just what I was looking for :slight_smile: What do I have to replace in the “Texture Replacement” code? Not sure, to be honest.