I have made a simple light manager script, it moves the lamps to empties at the nearest locations around the player.
script will explain itself, have fun with it.
# # Light manager by Cotax # # on lamp(s) add property: light # on placeholders(empties) add properties: # - light_source -> boolean -> True (on/off) # - energy -> float -> 1.0 # - distance -> float -> 4.0 # - color -> string -> 111 (rgb) #run scriptname.place_light from any object you like with always(true)->python(module) def first_run(cont): own = cont.owner own['lights'] = [obj for obj in own.scene.objects if 'light' in obj] own['light_sources'] = [obj for obj in own.scene.objects if 'light_source' in obj if obj['light_source'] == True] own['light_manager'] = True def place_light(cont): own = cont.owner camera = own.scene.active_camera if not 'light_manager' in own: first_run(cont) lights = own['lights'] light_sources = own['light_sources'] placeholders = sorted(light_sources, key=lambda light_source: camera.getDistanceTo(light_source)) i = 0 for lamp in lights: if (i+1) <= len(light_sources): lamp.worldPosition = placeholders[i].worldPosition lamp.energy = placeholders[i]['energy'] lamp.distance = placeholders[i]['distance'] r = float(placeholders[i]['color_rgb']) g = float(placeholders[i]['color_rgb']) b = float(placeholders[i]['color_rgb']) lamp.color = [r,g,b] i+=1 #else: #print('there are more lights then placeholders!')
Demo file: (P to play, W to move)
light_manager.blend (489 KB)