I am working on a small FPS-like game based very loosely off of the 3-d roaming ralph code pasted. I am stuggling with how to best simulate enemy/computer character’s vision. Right now I am casting a spotlight of a specified length. I also have a collision ray attached to each character/enemy. if the player is in that spotlight AND if the collision ray intersects the player’s collision sphere before anything else in the world, the enemy can see the player. (The collision ray is used to test to see if there is anything else in the world blocking the view of the player).
This works fine in very small flat world’s. The problem comes when using it on a large, hilly world. Essentially, even after pointing the enemy/character at the player, it is still possible for the ray to not hit the player based on the distance/angle of the enemy. This causes some really ‘blind’-like enemy behavior.
What I am thinking:
1.) Use multiple collision rays shooting off at different angle from the enemy.
2.) Shoot a ray only after the player is in the spotlight. The ray would then be shot directly from the enemy’s center to the player’s center (by calculating vector between the two)
Anyone have any other thoughts or better ideas for implementation?