Pathfinding and fog of war
by baylor wetzel · in Torque Game Builder · 07/26/2008 (9:34 am) · 2 replies
My pathfinding and fog of war system don't play nice together
This works: user presses a key, actor moves one spot, line of sight calculated, fog of war updated
i've just learned that the path created by the built in A* only has the end points, not tile-by-tile directions. So if i want to get from 0,0 to 10,0, the path only has 10,0. Which means onPositionTarget is only called for 10,0. That's where i put updateFogOfWar() so it only updates at the end of the path, making it look like you closed your eyes until you got to the end
i want to update the fog of war every time you enter a tile (or face a new direction). Anyone have a good idea?
Some options i've considered:
1. Put triggers on every tile, use onEnter(). Problem: This is a horrible idea
2. Schedule an event every x ms to update fog of war. Problem: Might not be very efficient
3. Write my own path finder that builds paths tile by tile. Problem: i'm lazy
4. Write something to convert the path from lines to tile-by-tile
Right now, 4 looks best, followed by 2, but i'm hoping there are better options
This works: user presses a key, actor moves one spot, line of sight calculated, fog of war updated
i've just learned that the path created by the built in A* only has the end points, not tile-by-tile directions. So if i want to get from 0,0 to 10,0, the path only has 10,0. Which means onPositionTarget is only called for 10,0. That's where i put updateFogOfWar() so it only updates at the end of the path, making it look like you closed your eyes until you got to the end
i want to update the fog of war every time you enter a tile (or face a new direction). Anyone have a good idea?
Some options i've considered:
1. Put triggers on every tile, use onEnter(). Problem: This is a horrible idea
2. Schedule an event every x ms to update fog of war. Problem: Might not be very efficient
3. Write my own path finder that builds paths tile by tile. Problem: i'm lazy
4. Write something to convert the path from lines to tile-by-tile
Right now, 4 looks best, followed by 2, but i'm hoping there are better options
About the author
Torque 3D Owner Randy Condon
Default Studio Name
I believe if you set that to false, the path will go tile by tile. I think setting to true eliminates any nodes in a straight line.
Alternatively, you could track the distance the object has traveled and when over a minimum distance (or rotation), recalculate the line of sight. (Just a thought).
Good luck and hope that helps.