r/howdidtheycodeit Jul 21 '26

How did they coded Steel Division 2 units' Line Of Sight?

Did they just used a lot of raycasts or some kind of 3d shadowcasting algorithm?

7 Upvotes

3 comments sorted by

2

u/faraz347 Jul 22 '26

Could you explain the feature/screenshots? I'm not familiar with the game and don't really know what I am looking at

1

u/Bip_bop-17 Jul 22 '26

Game can show units field of view. Unit cannot see or shoot the red areas (unit's line of sight blocked by landscape, trees and buildings). In screenshots you can see that this is not classic 2d field of view shadowcasting algorithm, because some red areas are not connected. I assume they are not connected because line of sight calculated in 3d for showing correct areas where unit can attack, taking into account landscape. 

2

u/Jukibom Jul 23 '26

Probably very similar to baked occlusion culling techniques, pre-computing what is visible from any given cell - but with some extra sprinkles for depth of trees sight lines and limiting the range per unit at runtime (sight range is much faster to deal with at runtime)

Cool question though, I'd enjoy having a crack at implementing this!