How To get light level at the player position

I’m developing a stealth game similar to Splinter Cell. But I need the ability to be hidden in shadows. How can i get the light level at the player’s position via BP? I found solution in C++, but I prefer working on blueprints, I searched all over the net and i couldn’t find solution for this in BluePrints. Temporary I created a new blueprint actor (a volume) called ‘Shadow’, but this is not a good aproach.
btw. I’m working with UE 4.8.1.
Any helps would be greatly approciated.

If you find C++ solution, you will be bale to recrete it in blueprint, functions in blueprints are the same once in C++. If you cant find functions you see in C++ it means they are not exposed to blueprint and you cant do that in blueprint (or else you find other way). Can you link to that C++ solution?

Thank you for your reply.

Hi Nyul,

I don’t believe we have anything exposed in blueprints that will let you directly get the light level of an object/surface. You could possibly accomplish something similar to Splinter Cell’s feature in blueprints but you would have to go about it another way.

  1. Use volumes for lit or shadowed areas and lerp the light meter accordingly.

  2. Get the lights within a radius of the player and get their radius and intensity. Then do a check from the players position to the light. This could become quite costly though.

Cheers,

TJ

I can try it, but I’m not sure I can recreate it in BPs, because the functions doesn’t matter, only the matematics part. I’m not really experienced in C++, I use it rarely. I’m more experienced in c#. I give it a try, and thank you again.

The solution you pointed, just using light components position in specific radius and preform Line Trace to detect if player is in shadow. It’s 100% possible in blueprint as math and line trace is available in blueprints.

If you have C#, you should able to to atleast read C++ code, just treat “->” as “.” in C# and FVector::Dist is static function call from FVector (in blueprint those don’t have “target” input). Majority of blueprint nodes are function nodes binded from C++, so they are exact same functions and have usally same names, UHT when C++ code is compiled takes function names and and add spaces before uppercaped letters or else they have custom names defined in UFUNCTION() (which is pretty common in math nodes), so i belive with just C# you should able to recretate this in blueprint one way or another

Thank you, very useful answer

Your answer is really informative, and useful, the second idea seams to be good for me. But what do I do when i have a directional light and my character is outdoors. I think volumes isn’t the best approach, it would not be too accurate and I would place so many of them on the map. So that’s the reason why I prefer the second idea indoors. But what do i do outdoors? Thank’s in advice

You could use one of the TraceForObject nodes and trace from the directional light to the player. If an object is hit before the player, they are hidden. If the player is hit then they are in the light.

Very nice answer, i didn’t tought of that, guys thanks for your help

thank you. Useful answer. I didn’t say i can’t read c++ code, I’m just not experienced in it.

It’s done, I post a screenshot maybe it helps somebody, here you go:

1 Like

Hi, and thanks for sharing your solution! But could you please make a screenshot in a higher resolution? It’s rather unreadable now.