Light meter system

Greetings!

I would like to create a simple stealth game, in which the player must hide in the shadows in order to evade guards. Thus, I wanted to create some kind of light meter, just like in the old Thief or Splinter Cell games.
It seems that doing it was pretty easy in UE3, but I can’t seem to find a tutorial for this on UE4.

I was told that trying to actually detect light exposure was kind of resource-consuming, so I gave up the idea. (Unless there is a good way to do it?)

In order to fake it, some people told me to create some trigger zones attached to the lights. The problem is that if there is a prop or a wall between the light and the player, then the system doesn’t work.

Therefore, I thought that maybe I had to use some kind of raycast system. For instance, if the player is near a light source, the light casts a ray to the player. If something interrupts the ray, then the player is hidden. If not, then his “visibility level” increases depending on the distance.
My main problem is that it works with spot lights, but I’m not sure how to deal with the light from the sky. Also, I worry about the refracted light, meaning that even when the player isn’t in direct contact with a light, he may still be in a very lit zone.

Do you have an advice on the matter? I’m not really a programmer to begin with, so I thought that the Blueprint thing could help…

Thanks in advance!

There is probably a combination of things that you will need to use to achieve this.

With a spotlight or point light you would want to setup a volume that matches the radius of the light that casts out a point value based on the falloff of the light. You would need to pair this up with a trace to the player to see if it hits and he gets whatever that point value is assigned to him.

For ambient light then things become a bit more difficult. You could go for a secondary trace to see if the light is bouncing around a corner to the player.


This 1 might take a bit of playing around to figure out just how you would do it but a simpler manual solution would be in your level to create another volume on the corners that acts like your point light but has the light itself turned off.

Lights can be really tricky, I guess.

Now that I think about it, the good thing is that my levels will be pretty dark. It will be mainly night time levels, with dull materials like cobblestone or plain wood, and the lights will be mostly torches, candles or fireplaces. Thus, there shouldn’t be too much bouncing lights. And if there are ambient lights somewhere, then I’ll just fake it with a zone, I guess.

Thanks for the link! I didn’t know we could do that.

But how would you proceed with skylights? Like, if for instance there is a full moon or a raising sun? Is there a way to detect that a ray touches the sky?

Do a ray trace from the player up to the light exactly the same way you would with any of your other lights.

Ray casting from head, chest and limbs would be required from character for each light in scene if you aim for a certain level of realism.

This won’t aim for the directional light “location” on the map? Then it’s more easy than I thought!

Yes, I thought about this problem. I don’t want the player to become invisible by hiding his face…!

Thank you people, I’ll work on this asap.