In my game the enemy has a script that check the position 25 far away from the enemy making a circle around him. I make and point 12 m away from the enemy. That works but not to well so I want to know a way to put the enemy like having a camera so that way he can detect some one in that angle then only in some distance the enemy can see you and if its posible put a var certainty that the enemy when you are closer he has more certainty and when you are far he has lower certainty that you are there.
Please if someone can help me I would greatly appreciate it. :)
asked Oct 22 '10 at 02:44 AM
One would typically use a Vector3.Dot solution for this. Dot products compare two vectors and determine the directions they are facing in. Subtract the player position from the enemy position to get the facing vector (this is the vector between the enemy and the player), then take a Dot product to determine how close the enemy is to matching that direction.
The script reference on Vector3.Dot is pretty good and has an example that fits your needs.
answered Oct 22 '10 at 03:44 AM