+1 vote

I have bumped into a random issue with my game. It's a 2D game with a bullet that I want to emit light as it travels across the screen. When it works it look good and I like it. But randomly it doesn't light up. I used to instance the bullet and I'd have the issue where some bullets would be lit and others wouldn't. I thought, well, maybe it's because I'm instancing the scene, so I tried adding several bullets off-screen and moving them onscreen and apply force to them, and when done moving instead of issuing a queue_free() I just stop their momentum and move them back off screen. But alas, the problem remains although with one difference. Now all of the bullets either work or they don't until you restart the program and you then have a chance that they will either work or not. I'm not sure if I'm doing anything wrong or if this is a bug.
Lit Scene - As expected
Unlit Scene - Unexpected behavior
I've tried this on a couple different computers. The OS I'm developing on is MacOS. I haven't tried on Linux or Windows yet. Another thing, I tried the current Stable build (2.1.1 and a Development build 2.2 Alpha) I am experiencing the same behavior on both Godot versions.

One more thing to note, my player character has a Light2d as well, but it's set to "Mask" mode, not "Add" like the bullet. The Light2d on the player always works I've never had it fail yet. So could it be an issue in the "Add" mode?

OK it's not "Add" mode, Light2d is randomly not working even with my bullets set to "Mask" mode.

-- Update --
So I decided to try to duplicate the problem outside of my game with a simple test app. No scripting just what you see for nodes, I made a couple images for the lighting textures. I have a simple sprite to act as the background. Another sprite with a light2d set to mask. And finally another sprite with a light2d set to "add". After restarting the app about 10 times or so I was able to show the "add" mode light2d not working, same bug duplicated without any code nothing moving nothing new being added to the scene and only a couple light2ds on the screen.
Not Working:
Not Working

in Engine by (27 points)
edited by

I do think there's a limit to how many lights can be in the screen at the same time (or was that in Unity?). Anyways, try shooting slowly and see if it fails anytime, then repeat the process but shooting fast. I remember seeing an option to change how many lights it could handle (or was that in Unity?), so you're not hopeless if it's this.

(I did find an light_discard_enabled option in project settings > render, but I'm not sure what that does)

Thanks for your reply mateusak, I'm not sure about the limit, but on the screenshots you see above there were only two Light2d nodes on the screen for both screenshots. One for the player, and one for the bullet. I also tried slowing the bullet down, but that had no effect either. I messed around with the light_discard_enabled option in setting, but neither setting had any effect. I did however make a discovery. If I disable my character Light2d in mask mode I am able to fire all the bullets I want on the screen without issue. I wonder if it's the two different modes of Lighting on the screen at the same time interfering with each other. I'm thinking I'll get rid of the Light2d on the player for now until this bug gets fixed... (if it is a bug).

I was not saying to slow the bullet, but to shoot slowly :P

Anyways, if you use a mask light just to black out everything around your player, you can use a CanvasModulate for that, and use a add light instead. Other than that, I don't really know what's causing your issue.

I know what you meant. I did both. Like I said there was only one bullet on the screen at the time each screenshot was taken. They only get shot one at a time anyway. Trust me I messed around with this for days before posting this. The only reason I am posting this is to find out if it's a known bug, which I'm guessing it's not. I can make things work by not using a light2d on my player, but it SHOULD work which is my point.

I got the same problem also in mac.......
a character with a light2d inside his node... that never fail
and other lights that work or not randomly...
in my case i set up all the lights in mix mode...
again.... no problem is detected if i take off the light of the character, but should work....
i think is a bug and should be revised
my lights are statics ... without movement.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.