Jump to content

wiki request : cone of vision


YouGroove
 Share

Recommended Posts

I would suggest you use three Plane objects. Project two planes(YZ) outward from your NPC's forward direction at the appropriate angles. then, create the third plane(YX) that is parallel to the NPC's forward direction at a specified distance away from the player, effectively creating an enclosed triangle. You would then check to see if the player is inside the enclosed triangle. Best of Luck!

Link to comment
Share on other sites

I actually think the best method would be to apply the raycast to my previous method. To adjust the method, I would preform a raycast a maximum view distance from the NPC's forward direction. I would then check for any collision with scene objects and adjust the far plane to be just before the location of the collision. Using a position just before the collision would prevent any abnormal detection for example, if the player was pressed up on the other side of the wall. I think the use of planes is better then just using a raycast because we want to check a certain area for a player and an exact position is not needed right away.

 

For example, I would check if there is a PlayerObject within the visible region of the NPC. If true, I would poll for the PlayerObject's position and through the use of the Vec3 class I would get the distance to\angle to etc and run any game logic from there.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...