I am 26 and I live in New Zealand. I am a hobbyist game developer.

Report RSS Giving NPCs Eyesight

Posted by on

I am currently creating an advanced npc system with c# in Unity. I am experimenting with giving the npcs eyesight so they can evaluate their surroundings. Currently the most effective method I have used is raycasting. I am concerned about how this would effect performance on a larger scale. Just a few npcs in the scene all shooting anywhere from 1 to 30 raycasts a second is ok but what about 50 npcs or even 100.

2018 09 12 9

Description of photo above:

The npcs is shooting 3 raycasts a second (blue rays) towards the player, if it hits the player then that indicates the player can see the npc. When the npc (small red person center of image) realizes it is in view of the player (green capsual) it shoots the yellow rays and then shoots a raycast from the player to the location the yellow ray hit. If the ray shot from the player hits a location within a close range to the yellow ray then that indicates the player will be able to see the npc if it tries to take cover there so the ray appears red, otherwise it shoots a green ray at the locations that are not within a close range to indicate better cover locations.

Another example:

Screenshot 23

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: