Field of vision

Recommended Posts

Hi! (I try(...) to explain my problem in english...) )
I try to program a Field of vision.
How for example in Commandos.
The enemy has a field where they see you.
A triangular form with a circle end.
(circlesector?? ) )
Hope you understand... )
Yeah... Now to the maths:
How can I calculate if a Point(X/Y)
is in this circle with angle and distance?
Thanks...
C.Ruiz
(How exactly can I show pictures on this forum?
If you show me I could send a picture...)
Edited by - cruiz on January 2, 2002 1:26:11 PM

0

Share this post

Link to post

Share on other sites

Anyway, here''s the simplest way: Keep track of a vector representing the direction the ai player is facing. Then, take the dot-product of that and the vector pointing towards the human player. If the angle is less than half of the field-of-view angle, then the player is in the field of view; otherwise he is not.

The dot product of two vectors, A and B, is expressed as follows:A * B = cos(angle_between_vectors)*(|A||B|)

To find the angle between them, then you need to do this:angle_between_vectors = acos((A*B)/(|A||B|))

The symbol |A| means the absolute value of A. This can be calculated as follows:|A| = sqrt(a.x2+a.y2+a.z2).

This does not handle occlusion detection. What that means is that, if you are behind a wall that the ai player is looking directly at, then he can still "see" you even though he shouldn''t be able to. From the sounds of things, you should be able to ignore this limitation.

Good luck.

0

Share this post

Link to post

Share on other sites

Thanks!Ok i''ve tried and it don''t works.But I don''t understand the theory either! What is if one or both vectors are zero??A "man" don''t must walk not? It can stand around for example.Ok explication to my game:You are a ship and you see the field of vision.If a opponent is in this field it should be visible.Here my source:

Share this post

Link to post

Share on other sites

Ohhhh!Yesterday did school begann.A math-teacher explained me a part of my problem.This formula is wronger than wrong!!!!!!!!!!I'm on it. I have changed the formul butI'm still working. But now I understand the theory!!(ok a part of it)I mean i had Vector-maths never in school.I will have in next semester i heard.Greets from here: C.Ruiz