• Create Account

Banner advertising on our site currently available from just \$5!

### #Actualnonoptimalrobot

Posted 21 August 2013 - 08:34 PM

Even if you didn't have layers (height) and the game took place in a single plane you would still have this problem.  It is essentially one of occlusion.  The player can be obscured from an AI's view by geometry in the horizontal plane.  To see what I mean just look at your diagram as if it was a top down representation and the different levels were walls.  I know, it's a drag.

The "easy" way to do this is as Zipster suggested but you'll have to cast rays in 3 dimensions and impart your tiles with height information.  Fortunately tracing rays though a regular grid can be done efficiently.  You can mitigate the cost by not casting all your rays each frame; human AIs modeling vision rarely need to be updated every frame.

A hacky way to do the same would be to buffer a no-visibility zone around the border of elevated levels and scale the extent of the zone based on the distance an AI is to the edge.  Each AI would need to track it's own scaling factor.  You can work out the amount of scale with some simple trig.  Even if you do this it's a limited solution that doesn't solve any of your other visibility problems.

HeightOfAI / DistanceToEdge = HeightOfLayer / OcclusionDistance

OcclusionDistance = HeightOfLayer * DistanceToEdge / HeightOfAI

### #1nonoptimalrobot

Posted 21 August 2013 - 07:40 PM

Even if you didn't have layers (height) and the game took place in a single plane you would still have this problem.  It is essentially one of occlusion.  The player can be obscured from an AI's view by geometry in the horizontal plane.  To see what I mean just look at your diagram as if it was a top down representation and the different levels were walls.  I know, it's a drag.

The "easy" way to do this is as Zipster suggested but you'll have to cast rays in 3 dimensions and impart your tiles with height information.  Fortunately tracing rays though a regular grid can be done efficiently.  You can mitigate the cost by not casting all your rays each frame; human AIs modeling vision rarely need to be updated every frame.

A hacky way to do the same would be to buffer a no-visibility zone around the border of elevated levels and scale the extent of the zone based on the distance an AI is to the edge.  Each AI would need to track it's own scaling factor.  You can work out the amount of scale with some simple trig.  Even if you do this it's a limited solution that doesn't solve any of your other visibility problems.

PARTNERS