Change diffuse colour by keyboard?

Hi there, Ive got a little problem... I want to change the diffuse-colour with the up-arrow. The goal is to create something like a colourpicker... controlled with the arrow- keys. Ive tried it with an action (frame 1= red / frame 11= blue) but it wont work…
can anybody help me out?

Btw.: I`m not familiar with python.

There are a few methods:

  1. Vertex colors (controlled in game by python)
  2. Animated color channel (controlled in game by action actuator)
  3. Animated Object Color (controlled in game by action actuator)

I’d probably go with #3:

  1. Go to the material pane, and on the objects material, check the button ‘Object Color’
  2. Go to the object pane, and look for the object color color picker. At frame 1, have one color, hover over the picker, press I to insert a keyframe
  3. Repeat step 2 for all the colors you want (putting them on different frames)
  4. In the logic editor, add a game property ‘color’
  5. Add a keyboard sensor and property actuator to cycle the number up and down
  6. Have a property ‘changed’ sensor connected to a action actuator. The action actuator should be set to set the active frame to the property value.

Hope that helped. If you need more detail on a step, just ask.

Hi sdfgeoff,
I got it. Thanks for the detailed answer! Now I`ve created an action with 100 frames and 10 different colours.
I want to flipp between the keyframes with the arrow-keys (up=next colour/ down= previous colour). How do I handle this?
[Edit] Is it possible to do that by a driver (driver translation = colour changes)? [/Edit]

One way with logic bricks is to use ten (X2) action actuators in ten states. Every time you press up an action will play from this frame to that frame and the next state will be set. The same thing with pressing down, except then the previous state will be set. Make a loop, so the next state on the tenth will be the first and the previous state on the first will be the tenth.

or python.
copy the logic bricks, game property and the scripts
change the action to your object’s Action.
hope it helps.


color.blend (424 KB)