2D Ray Tracing - Piecing together the tutorial..

Hi all,

I’m attempting to implement a limited field of view feature by introducing ray tracing to shadow out everything not insight.

I’ve stumbled upon this “tutorial” which has the effect I’m after. Unfortunately, the video is loosely explained and is more of a technical demo:

Code provided by author: Scritps - Google Drive

Code has been provided in the videos description and while logically it checks out - I see no rays being cast (ingame and scene). The only effect I get is objects dimming or lighting up depending on player distance, the rest of the screen is black.

The walls I have added all have the component “box collider” and aside from that I unfortunately don’t have much to go on.

I feel this is a unity configurations issue rather than code and I’m new to unity so I may be missing something obvious. If anyone has 15min spare to tinker and figure out the missing component it would be a good share for the community.

Thanks in advance!

Have you seen Reb Blob Games’ 2D visibility article?
https://www.redblobgames.com/articles/visibility/

1 Like

Hey Olmi, that’s a great share - Thank you for that!

Honestly the logic/algorithm aspect of it is fine, my short fall is not knowing the unity environment. I think my issue with the initial youtube example above is something to do with either layers or materials assigned. Not sure, still trying to deduce the issue