YouGroove Posted January 12, 2014 Share Posted January 12, 2014 Well just asking if someone have some math cone of vision for NPC seeing or not the player ? A simple 2D cone of vision on XZ plane. For example NPC can see player if player position is between 80 and -80 angle degree. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Joshua Posted January 12, 2014 Share Posted January 12, 2014 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! Quote Link to comment Share on other sites More sharing options...
SarperSoher Posted January 12, 2014 Share Posted January 12, 2014 That wouldn't respect occlusion (What if the player's behind a wall?) , multiple raycasts is a better solution. Quote Link to comment Share on other sites More sharing options...
Joshua Posted January 13, 2014 Share Posted January 13, 2014 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.