2018-07-25-ean
Blender Flashing light for game engine
To make a light flash on random time on blender game engine, use the game logic, and connect the light to a custom python script, with this content:
import bge, random, math
obj = bge.logic.getCurrentController().owner
print ("here")
if math.fabs(obj["intensity"] - obj.energy) < 0.2:
flash = random.randint(0,300) < 1
print("Flash = "+str(flash))
if flash:
obj["intensity"] = random.randint(0,5)/10
else:
obj["intensity"] = random.randint(10,11)/10
obj.energy = obj["intensity"]
next_step = obj.energy+0.3
print("light change"+str(obj.energy))