Flashlight with scattering effects/Ambient light

I have a flashlight setup with a spotlight for shadows and a point light for ambient light. Now what I need is for the point light to go as close to the wall as possible without going through when the player approaches the wall, and when the player backs up from the wall the light should still stay near the wall until the player is further away.

I’ve tried using a bone parent setup for this. The point light is the sensor which detects the property ‘Wall’ and triggers a controller on the bone to animate it’s scale so that when the bone shrinks it pulls the point light with it, closer to the player. The problem is when the player moves away from the wall, the light stays close by the player.

Could someone explain to me what I’m doing wrong with the logic bricks or maybe a better way of doing it with python? I would really appreciate it.

Edit: And you can press rmb to unparent the flashlight to see the point light better

Attachments

Ambient_Light_Bone_Anim.blend (1.94 MB)

here you are sir :smiley:

Ps- forgot to set shadow only

btw- this is a great idea!

“scattered spot” :smiley:

Attachments

GeoLight.blend (480 KB)

Hey thanks! You are most helpful :smiley: I think it would be good for horror games, or really any game with a flashlight I guess. :slight_smile:

That’s good thinking using the ray, however I see two problems with this solution:

  1. When you move the light to another smaller room there’s a very fast change, you can see this if you put the light on to the rocking chair too, it will flicker.

  2. When the ray range is put to 10 and it can’t reach a wall then the light goes back to the source(the flashlight), ideally the point light should stay at a distance of 10 blender units until it hits a surface.

A way to solve #1 might be by making the transition from surface to surface a little bit slower, maybe a second or so of time before the light transitions, so the eyes can adjust better. Is something like that possible?

#2 Could be solved by simply making the light stay at the 10 range, if that’s possible.

Thanks again BPR, and if anyone else would like to help, use my blend, as the surfaces in it are better for testing.

Here:

Attachments

GeoLight_Setup.blend (1.96 MB)

Just comment out your else statement and it will stay at the ray range if thats what you are asking for :slight_smile:

Because if the sens is positive it will be on the wall but if its not it will return to your own (your lamp holder) and if you comment it out it will just be false and stay where it was (might be a bit confusing xD)

The flickering can be solved by easily adding simple collision boxes on the chair and maybe add a weak spot light on the lamp which makes it a little more light in front of it instead of just the spot you are pointing on. I might missunderstand you but please explain if i did xd

I just need to do,

else:
lamp.energy=.1

it’s too bright when it snaps back

but lights are instant, :smiley:

Zehrox - hmmm, well if I comment the else statement out it the point light stays farther away but then it has no interaction with the surfaces, so I’m probably not getting what your saying.

The collision box on the rocking chair would resolve the flickering when the light goes in between slats, but once the ray goes off the rocking chair onto the wall behind it there is still the problem of drastic light changes that don’t look natural. You can see for yourself by downloading the blend, hitting right mouse button once in game, and then moving the player in front of the flashlight, this is where it’s at it’s worse imo.

BPR - Hope that solves it, but I think you should try what I just said to Zehrox.

And thank you both!

Try this :smiley:

A-D rotate light

1B looks best to me (@zehrox ) method

Attachments

GeoLight.blend (477 KB)GeoLight (1b).blend (480 KB)

To add to realism, you can set the “bounce” lamp’s energy to be less, the further the ray length.

Great idea :smiley:

Attachments

GeoLight (1C).blend (481 KB)

Attachments

GeoLight (1C) (1).blend (479 KB)

1C looks a little better but, the flickering is still there. I know you say that light is instant, but there needs to be a slow shift in light when it gets shined into a room.

BPR, why don’t you use my blend for testing? It’s got a better “real world” environment that is better for tests, use it and you’ll see what I’m talking about with the flickering. I’ve put all the stuff from 1c into it. Please tell if there’s a reason you don’t use this one:

Attachments

Please_Use_This_One.blend (1.96 MB)

the “hot spot” of a flashlight is wider then 1 ray, we need a “big fat ray” to and get a average,

or have a point light on the flashlight tip,

GeoLight_smoothtest.blend (1.97 MB)

Heres a little smooth test, dont know if that is what you are looking for, might give an idea. its a bit buggy sometimes, especially in the room, where i focused the most to get the smoothness done.

BluePrintRandom has a really cool/good system there btw.

So as long as we are sampling things, why not color? :smiley: We could use this to do fake color bleeding.

Shine the light on the red door. I’m sure someone could do it better in python though.

Attachments

Fake_Color_Bleeding.blend (1.98 MB)