Search Unity

Line of Sight for AI Director type mehanic

Discussion in 'Editor & General Support' started by jefft, Feb 26, 2012.

  1. jefft

    jefft

    Joined:
    Feb 20, 2012
    Posts:
    23
    Hi people,

    I want to do something a bit like L4D's AI Director. I want to have graffiti, posters, etc that change according to the situation. However I don't want the player to ever *see* it change, because that would break immersion. Unfortunately the stuff I saw on the forum about testing if an object is visible didn't pan out... apparently the API considers an object to be visible even if it's occluded. ;)

    The physics raycasting method has obvious flaws, because the quality depends upon the number of raycasts you make. For this purpose false positives are okay (saying it's visible when it's not), but false negatives would be bad.

    My current thoughts are as follows:
    - When really far away assume it's not visible, nobody will care if 2 pixels on screen change.
    - When medium far away use raycasting after checking it's within the view frustrum. The further away something is the closer to parallel the raycasts will be, therefore the more accurate.
    - When close check if within the view frustrum. Do raycasts to the bounds of the object, and unless all raycasts hit the same collider assume it will be visible. This means if it's fully blocked by a floor or wall you can't see it, otherwise assume you can.

    Another possibility is to use a portal type approach to check if a whole area is visible, but I don't like the idea of the designer having to manually set up portals PVSs because there could be mistakes. I don't see a way to automatically calculate the partially visible set using Unity.

    Any better suggestions? Pros or cons to my suggested method?
     
  2. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
  3. jefft

    jefft

    Joined:
    Feb 20, 2012
    Posts:
    23
    I believe I tried that one too. Confusing because a number of methods are similarly named. They say "during the culling process", maybe that's before the culling decision is made?
     
unityunity