• Register

Fractured State is an urban combat real time strategy game that takes place in the pseudo diesel/steam punk decay of the nation of Laperia. It features simultaneous interior and exterior combat to power building-to-building fights, cover and flanking, and weapon accuracy modelling and reloading.

Post news Report RSS Fog of War Implementation

I've seen a fair number of people posting on the Unity user forums over the years about how to implement some type of shroud or fog of war system. We were on the fence about whether or not we wanted it at all for Fractured State but after a couple rounds of play-testing we were pretty much all in agreement that not having it was confusing to the player. So - off I went; and I figured I would share some details on how I accomplished it mainly because it's a much simpler implementation.

Posted by on

I've seen a fair number of people posting on the Unity user forums over the years about how to implement some type of shroud or fog of war system. We were on the fence about whether or not we wanted it at all for Fractured State but after a couple rounds of play-testing we were pretty much all in agreement that not having it was confusing to the player. So - off I went; and I figured I would share some details on how I accomplished it mainly because it's a much simpler implementation as compared to what I've seen suggested in the past.

So the caveat here is that we are using a purely "fog of war" system - and a slightly stripped down one at that. I've always defined fog of war as: The area not within any player unit's vision range that is drawn in a slightly darker shade; and shroud as: The area of the map that the player has not explored and is therefore completely black. Most fog of war systems will also maintain enemy building positions as they were when the last friendly unit left the area. We have no base building so the only structures present on the map are the ones put their by the map maker so that last part doesn't make any sense for us. We also opted for no shroud because we don't have a minimap in the traditional RTS sense (more on that in a few weeks). We're also using a more rigid line of sight evaluation where buildings and props can obscure enemies. Therefore, all we really needed was some visual indication as to our unit's sight range. Here's how I did it.

Unit's sight range is represented by a big sphere around that unit. I used a circle mesh and scaled it according to the unit's sight and made sure it followed the unit around. This is essentially the circle created when the vision sphere intersects the ground.

shroud_002

These circles get rendered on a separate layer against a black background and the resulting image is multiplied into the main camera.

shroud_001

Already a majority of the way there - but there are some issues. Those circles will render over top of everything so when I swing the camera around to a point where a building obscures most of my view I end up with something that doesn't make any sense.

shroud_003

I solved this by rendering "doppelganger" buildings into the fog of war layer and toggling them either white or black depending on whether or not they were within vision range. This masked the vision circles and allowed buildings to pop into view when a unit got close to them. Here's the final result with a blur effect applied to feather it out a little bit.

shroud_005

This was immediately handy because it revealed that the Conscript's vision range was pretty large, and it's also a nice effect that helps to focus the player onto specific areas.

So there you have it - our fog of war implementation! Thoughts? Leave them in the comment section!

Post comment Comments
Carens
Carens - - 217 comments

Although It is very Simple I really like it...:)

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: