This question again: Glowing or light emission!?

I have searched and searched and searched, and the most recent thing I have seen was 2009. I need to make objects glow, or emit light. In my specific case, a laser. At first it was just a green line, but when it passed by objects without casting light it looked really silly. I’ve tried parenting a light to it matching its color, but point lamps are the only thing that make sense – and point lamps can’t be stretched into a line to match the shape of my laser.

That technicality aside, it’s also making it difficult to script. I am using an add object actuator to create the laser which has a light parented to it. This works the first time. When I fire again though, the old laser remains (they don’t move yet … one step at a time for me, haha) and the light transfers to the new one. So I end up with 20 floating lasers and one light. So I need 2 actuators to create a lamp and a laser and then parent the lamp to the laser every time the player shoots? I … it seems like a hack job, and I don’t like hack jobs. I want this done right.

Thanks in advance for the help. :slight_smile:

So firstly you do not need to add both objects seperately, you can parent the lamp to the laser ( in Blender and Not while in game), just add the laser with an actuator and the lamp will automatically be added as well.

Secondly, a glowing effect is really not easy, you could try using a glow Filter, but in my opinion there is Not really One working well.
So I recommend you to use a texture on a plane that lies on the Laser.
the texture should be a blend.

Sorry I know that was a really Bad Explantation, i am Writing on my iPad and the Auto correction is really annoying.
so if you want I will Upload an Exempel of what I mean!

Currently this is what I am doing. I have to guns firing at the same time, both using an edit object actuator adding the ‘laser’ object I created with a lamp parented to it. The problem is that the lamp only stays on the last item created. If I fire the guns 20 times, only the 20th laser has the lamp.

I think I understand what you’re saying. In my case this wouldn’t work well for me. It would be far too obvious it was a blended plane. However, I may be misunderstanding, so a example would be really great! :smiley:

I do not really understand how your laser system works…
So when you fire a gun you add a laser with a lamp, how long is it expected to stay in the scene?
And as soon as you add a new laser the lamp of the old one will disappear?

I’m apparently unable to upload my blend. Hmm… Do I not do it via attachments? I figured I’d just post what I’ve got and let people see how horrible of a job I’ve done, haha.

EDIT: I should probably at least explain better though. It’s basically a buttlet, but stretched to about 2 blender units and is green. There’s 2 guns on the ship firing simultaneously, but in the script the left is fired first. When I hit <P> and fire, only the right side has the lamp, which zooms off into the distance. I can keep firing to create more lasers and always the last laser fired is what has the lamp. The others do not. To help visualize, it’s a Star Wars style laser, and not a Star Trek continues beam. Hope that helps.

import bge

def main(controller):

  owner = controller.owner
  shoot = controller.sensors["shoot"]
  if shoot.positive:
    origins = [child for child in owner.childrenRecursive if child.get("isProjectileOrigin")]
    for origin in origins:
      actuator = origin.actuators["add_projectile"]

The owner is the player object – in this case, the spaceship. I have an add_projectile actuator on an empty object just in front of the gun it is parented to, which is parented to the ship. The empties has a property isProjectileOrigin boolean set to true. I need to have it this way as future plans are to have ship components be modular. I don’t want all my logic and properties attached to the player. Of course, if there’s a way to do this and have it be simpler I’m all ears. But I digress. I think maybe my method of doing this is causing the light to not show up properly? It’s the only thing I can think of…

I understand your problem. You can only each light only once, so adding the same light twice will just have the same effect as moving the light to a new location.

If you want the laser to look like its glowing and you don’t need it to illuminate anything, then use a Bloom 2DFilter or make blurry glow texture, map it to a plane and add to the laser mesh.

If you need the laser to illuminate stuff like and look just like a laser then you can add multiple lights in a hidden layer ( I think the limit is 8 but 2-3 should be enough ). Make a Python script that will spawn those lights in order. So if you use 3 lights and you shoot 5 times the script should spawn your 3 lights for the first 3 shots and then for the 4th and 5th shot use the first and second light again.

The second solution won’t work, I know that. The “end game” is for this to be a multiplayer game, which means loads of lasers flying everywhere. If they suddenly stopped illuminating it would look bad.

So, I’m curious about this bloom effect. This is probably what I want. I mainly just want objects the lasers pass to be lit as they’re being passed, simply for a cool effect. I had imagined two ships in a dogfight, and seeing the enemy’s lasers illuminating your ship as they narrowly pass by would be super cool. That and fighting through an asteroid field – seeing the asteroids light up as lasers wizzed passed. If the blur can even half achieve this then I’m sold.

There’s my current file I’m working on. I’m hoping someone could see what I’m doing and either think of a good solution, or advise further on Josip’s solutions. Also, you’ll notice the offset of the laser fire. ANY help on that would be appreciative. I’ve been beating my head against the wall on that for a while now. Thanks guys!