light that follows bullet

Hello I have a point light parented to my bullet mesh. when I create my bullet the lights always move to the position of the most recent bullet fired

               
def spawnBullet(cont):
    own = cont.owner    
    new_bullet = own['scene'].addObject('bullet', own['barrel'])

how do I get the bullet to follow its parent mesh.

I only have this problem with lights. Not with other objects.

You can only add a light once I believe.
So when you add it a second time, it meerly removes the first one, and only the second one glows.

Bit of a pain really.

Solutions:
Um…
Duplicate the bullet a couple of times, and then add them in order, so the effect is not noticeable unless you have lots of bullets in the air.

Uhm my test was a bit “mute”.
I tested a new years fireworks scene some time ago and I was told and I later noticed that if you have a light on passive layer, you can add that light as many times as you wish.

For example:


new_light = scene.addObject('light', bullet, 0)
new_light.setParent(bullet)

This would parent the light to the shot bullet.
EDIT: Argh sorry, so you can’t add the same light multiple times.
I tried to find my other test file I made at new years (fireworks with added lights), but no luck.
I managed to find a pretty clean method back then to do this. I’ll post it if I manage to find it.

you would have to have multiple copies of the bullet object with lamp child on the inactive layer. bullet1 with lamp child, bullet2 with lamp child, bullet3 with lamp child…Im not sure the max…but i think its like 9 total lamps of any type in the scene. Then do something like


if not 'init in own:
     own["lampcount"] = 1
     own["init"] = 1

if bulletshoot:
     scene.addObject(str("bullet"+own["lampcount"]), bullet_origin, 0)
     own["lampcount"] += 1
     if own["lampcount"] == 6: #(or whatevermax)
          own["lampcount"] = 1

thats how i would do it
and i would have at least some amount of length of time for the bullet

Thanks guys. This is what I have done and it works. I made a bullet group that consisted of my bullet and lights parented to it in another blend file then linked the group to my game file on an inactive layer. I duplicated the linked group 10 times and stored their names in a list. When I spawn a bullet I just go through the list on names until I get to the end of the list then start back at the beginning.