How do you handle NPC vision in 3d ?

Started by
0 comments, last by Ingenu 24 years ago
Designing a fantastic game, I''m thinking of the NPC. They must saw the PC, but how do they detect him, or environnment modifications ? I''ve thought of making one or more list containing the objects that have been moved and the characters. Using quadtree I might put the list as a ''cube'' var. Using portal I might put the list as a ''section'' var. The NPCs will check the objects in the list against their view frustrum and reacte appropriatly. Is there another faster/easier/best solution ? -* Sounds, music and story makes the difference between good and great games *-
-* So many things to do, so little time to spend. *-
Advertisement
For spotting the PC, I would consider some sort of ray-casting algorithm. If you cast a set number of rays from the NPC each time, this also accounts for characters being less obvious if they are further away (if that is what you want). Alternatively, cast a ray from the PC to the NPC and see if (a) it reaches without hitting something else first, and (b) it hits the NPC within their field of vision.

As for ''environmental modifications'', I think the simplest way would be to just set a flag, to say whether something is modified or not. Then assign a probability of detection dependent on the size of the object, how obvious a modification would be, and how close/how aware the NPC is. You can use the above method or some other to determine if it''s visible or not.

Not that any of the above ideas reduce the benefits of sectors, quadtrees, etc. It''s always good to be able to trivially eliminate a large amount of your database.

This topic is closed to new replies.

Advertisement