Only one child light source for parent objects created multiple times

I have a minimal knowledge of Blender because two classes in my course requires it. I'm making a game where a cannon shoots at targets. I've decided to make a night level (the day level is 100% working) and add point light sources to the targets and the ammo, which is a ball.

I created a point light source and added it as a child to the ball. Both are located on a different layer than the "shooter". When I fire a shot, the light follows the ball as expected. But when I fire several shots, there's only one point light source and it follows the last ball fired, jumping from ball to ball as I fire them.

I've searched a bit and I found out that that may be impossible, but I'm not sure, so that's why I'm asking if it can be done and how. I'm not in a hurry since this is not mandatory.

Using Blender 2.73a in GLSL mode (can't change that) in Windows 7 Ultimate.

Thanks in advance.

• Welcome to BSE! Yours is a known problem with the game engine, (found that out last week) and as far as I know, there is no solution, I'm very sorry. – Scalia Mar 16 '15 at 17:40
• Thanks for your comment. Considering your experience and that link, there really must be no solution. At least it's good to know that for sure. – GuiRitter Mar 17 '15 at 18:26
• I wouldn't base too much off my experience, but I think that link states I pretty clearly as a bug that needs fixing. :D – Scalia Mar 18 '15 at 17:51

1 Answer

This solution, is called a FX lamp lending library.

Add a bunch of FX lamps like lamp1, lamp2, lamp3 etc,

Parent them to a object, name it LampFX, set each lamp energy to zero

Add a property in each lamp "Lamp"

Have the LampFX object run this (one time)

#build lamp list
import bge
cont = bge.logic.getCurrentController()
own = cont.owner

if "LampList" not in own:
Lamps =[ ]
index=0
for child in own.children:
if "Lamp" in child:
Lamps.append([child, False])
child['index'] =index
index+=1

own["LampList"] =Lamps


When a projectile is added to scene, use

added = own.scene.addObject("projectile", own, 0)
for Lamp in own.scene.objects["LampFX"]["LampList"]:
if Lamp[1]==False:

Lamp[0].worldPosition = added.worldPosition
Lamp[0].setParent(added,0,1)
Lamp[1] = True
Lamp[0].energy = 1.0
break


Now the lamp is "checked out"

Now, before the projectile is deleted, a script needs to put it back and check it back in, so another projectile can chexk it out again.

for child in projectile.children:
if "Lamp" in child:
own.scene.objects["LampFX"]["LampList"][child[index]][1] = False
child.removeParent()
child.energy =0.0

own.endObject()