How would you make the vision cone, render and detect higher or lower elevation?

Hello,

I am making a game similar in mechanics to desperados 3 and i am kinda stuck in the vision cone department.

I’ve managed to create a flat cone on the ground by referencing a fan of ray traces coming out from my units, and then projecting a procedural mesh on the ground bellow. (i’ve also seen and spoken to someone about a vision cone driven by scenecapturecomponent2d and decals but i have no idea where to even start with that)

My issue is that there is no way to have that accurately depict the cone on higher or lower surfaces with taking vision angle into account.

My though was something like taking each ray, sub-diving it into a few smaller portions then casting rays up and down and checking if it meets with navmesh grounds to then project there the appropriate cone texture (full for clear vision, stripped for obscured) based on distace or something like that.. i don’t know for sure as i haven’t implemented it yet.

Basically i can’t figure out how to make it like in the screenshots above, where when the guard is at the back of the balcony, he can only see further down bellow, but when he comes close to the edge, his vision on the ground floor comes closer to the cutoff. And also while all this is happening, the railing is also causing a section of the cone, the one on the ground closest to the balcony, to be obscured.

I’ve though about making a frustum and just casting rays all over to all directions, but that seems way to expensive and excessive.

Any thoughts? Please i’m stuck :frowning: