Game Object: color

color
  • gets/sets the object's color.

Type:  float list [ r, g, b, a ]
  • r = Red.  Range: 0.0 to 1.0
  • g = Green.  Range: 0.0 to 1.0
  • b = Blue.  Range:  0.0 to 1.0
  • a = Alpha.  Range:  0.0 to 1.0
Note:
  • Object Color must be enabled.
     
  • Properties >> Material >> Options >> Object Color
Sample Code

################## get the game object's color
 
# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get object that controller is attached to
obj = cont.owner

# get the color
paint = obj.color

Sample Code

################## set the game object's color
 
# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get object that controller is attached to
obj = cont.owner

# set the game object's color to blue
obj.color = [ 0.0, 0.0, 1.0, 1.0]