How to detect the sunlight hitting a part?

I am trying to make something big but right now I need to start small. How could you detect the light hitting a certain part, if there was a house map and it was at 11 Clock time it would be the light would hit the roofs, or hitting the street. How could I get whatever the sun light hits and tells me. This is very complex so I came to DevForum to get my question solved.

Sincerely,
TheSharingan321

1 Like

You could try creating a Ray on that Sun’s look vector. (I forgot the exact way to grab the sun’s look vector, reference the wiki). However, since a Ray is thin, I’d suggest creating a region along that ray’s length. You could make the region’s size dynamic, depending on the Sun’s size. Rays and Regions are datatypes so they’re automatically garbage collected, you shouldn’t have any memory issues.

This seems pretty unachievable though, I’d just keep this local, as in dependent on a client’s camera. If you were to try to pick up everything the sun touches, you’d be quite disappointed to find out that a sun’s range on an x and y scale is infinite. It touches everything except something in a shadow. Essentially, the bigger the map the bigger the region would need to be.

Perhaps this will help. Mentions GetSunDirection.

1 Like