However, as I was testing this code, I’ve realized that the weight of these values differentiate depending upon the location of the light. I discovered this largely by testing with point lights and finding the outer barrier of where you “should” be visible.
For example, when I place the point light at around a medium height, the numbers indicate that I should be out of the light when the brightness is less than 0.003. However, when I have the light at a higher elevation, the numbers indicate that I should be out of light when the brightness is less than 0.004. With these differences in numbers, I don’t know what numbers to use to safely determine if a character is out of a light or not.
Is there something wrong with my calculations? Should I do something to take into account the elevation of the light component?
Your code looks fine to me! Are you saying that visually when you look at the character the amount of light it receives on the screen is different from your numbers? If so, then it could be that your lights aren’t using an inverse square law?
Well, I’m just using a default point light for testing purposes, which, unless I’m mistaken, automatically uses the inverse square law. And what I mean, is that when in first person (the game is first person), what looks to be “in the shadows” occurs at different numbers depending on the height of the point light.
Just to show you, I’ve attached 2 images: the first image was when the light was set at about eye level and the second image was when I moved the light farther up.
Well if you move the light higher up, ie further away from the floor then I would expect it to become darker because it’s further away (unfortunately in the forum the images are in the wrong order!). Maybe what you should be doing is instead of using the straight GetActorLocation() for your character, apply an offset to get the light intensity at their toes, rather than their normal origin?
This won’t work if your actor gets tilted. The other way - which is what I would do, but it’s slightly more involved - would be to add a socket to your mesh and use it’s location instead. That way you could easily manipulate it in the editor to move it.