Implementation of "fog of war" et al
by Aaron Soules · in Torque Game Builder · 01/26/2006 (6:59 pm) · 4 replies
Hey all,
I've would like to add some elements from games like starcraft where you can "discover" terrain, but then if you leave fog of war will cover the area, allowing you to see terrain but no movements.
I have a few ideas of how this could be done, but i don't know torque well enough to know how feasible they are. Please tell me if this is a terrible way of approuching this problem.
First, undiscovered terrain would be a black layer above all the terrain and units, etc.
Second, fog of war would be everywhere that your unit(s) is not.
First question: Is it possible to slowly "discover" the terrain by making the top black layer fade to transparent as a unit walks?
Second question: Is it possible to hide changes (enemy unit movement, changes to terrain, etc) from the unit(s) when the player(human) is looking over terrain that has fog of war over it (explored, but no nearby units)? this would be indicated by a semi-transparent black layer.
Third question: Is it possible to "fog" behind a unit, but not in front of the unit, and more specifically "fog" behind objects that might be in front of a unit.
I realize I'm thinking pretty "out there" at this point in time, but I'd like to know just how far "out there" I'm thinking.
I've would like to add some elements from games like starcraft where you can "discover" terrain, but then if you leave fog of war will cover the area, allowing you to see terrain but no movements.
I have a few ideas of how this could be done, but i don't know torque well enough to know how feasible they are. Please tell me if this is a terrible way of approuching this problem.
First, undiscovered terrain would be a black layer above all the terrain and units, etc.
Second, fog of war would be everywhere that your unit(s) is not.
First question: Is it possible to slowly "discover" the terrain by making the top black layer fade to transparent as a unit walks?
Second question: Is it possible to hide changes (enemy unit movement, changes to terrain, etc) from the unit(s) when the player(human) is looking over terrain that has fog of war over it (explored, but no nearby units)? this would be indicated by a semi-transparent black layer.
Third question: Is it possible to "fog" behind a unit, but not in front of the unit, and more specifically "fog" behind objects that might be in front of a unit.
I realize I'm thinking pretty "out there" at this point in time, but I'd like to know just how far "out there" I'm thinking.
#2
when I'm adding a sprite where do i specify which layer it is on?
01/27/2006 (10:06 pm)
Thanks! glad to hear I'm not crazy after all.when I'm adding a sprite where do i specify which layer it is on?
#3
01/28/2006 (11:58 am)
Every object in T2D is derived from t2dSceneObject. Look in the reference docs for .setLayer();
#4
01/28/2006 (4:01 pm)
Thanks, i've fixed the problem.
Torque Owner Jason Cahill
Default Studio Name
Question 2: You have to build your own visibility determination code. If a tile is showing the FoW, then you should hide the sprite on that tile.
Question 3: Yes. T2D supports 32 "layers" so you can decide which layer has terrain, which has sprites, and which has fog.
None of these questions are out there, nor are your solutions.