Advertisement Jump to content


This topic is now archived and is closed to further replies.


How do you handle NPC vision in 3d ?

This topic is 6851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 *-

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!