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.

  • 2
    $\begingroup$ 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. $\endgroup$ – Scalia Mar 16 '15 at 17:40
  • 1
    $\begingroup$ 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. $\endgroup$ – GuiRitter Mar 17 '15 at 18:26
  • $\begingroup$ 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 $\endgroup$ – Scalia Mar 18 '15 at 17:51

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 =[ ] 
    for child in own.children:
        if "Lamp" in child:
            Lamps.append([child, False])
            child['index'] =index 

    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[1] = True
         Lamp[0].energy = 1.0

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.energy =0.0

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.