tformnormal / tformvector are another way to check if something is within a field of view.
Basically do this:
TargetEntity = handle of entity you wish to see if it is within view.
EyeEntity = handle of entity which is trying to see something
ICanSeeYou=false
Tformnormal Entityx(TargetEntity)-Entityx(EyeEntity),Entityy(TargetEntity)-EntityY(EyeEntity),Entityz(TargetEntity)-Entityz(EyeEntity),0,EyeEntity
;assuming that in eyeentity's space z = forwards
;SomeFactor# is a value between 0 and 1.0, which you want to set the value close to 1.0 if you want a narrow field of view (1.0=dead ahead). A value of 0.0 would make the field of view a hemispherical one. As a suggestion try a value of about 0.7 to start with.
SomeFactor#=0.7
if TformedZ()>SomeFactor# then
;ie we are in the field of view....so alright to do a linepick now as they are quite slow...(there are other ways of doing it without a line pick depending on your geometry)
radiusoflinepick#=0.1 ;you set this value to what you feel is appropriate
Entity=linepick( Entityx(EyeEntity),EntityY(eyeentity),entityz(eyeentity),Entityx(TargetEntity)-Entityx(EyeEntity),Entityy(TargetEntity)-EntityY(EyeEntity),Entityz(TargetEntity)-Entityz(EyeEntity),radiusoflinepick#)
if entity=targetentity then ICanSeeYou=true
endif
This way you only do the linepick if the entity is within your cone of view. I try to avoid the picking commands whereever I can as I have a slow Pc.
*Edit = forgot a pair of brackets around the linepick expression.