   How to see if one sprite can see another sprite
  I'm trying to determine mathematically how one sprite can see another sprite. I have a guard object, and I only want to initiate action if the guard isn't looking in a character's direction.I have the guard's position and direction, both as D3DXVector3 vectors. And I have the sprite's (the non-guard units) position and direction vectors. But I can't figure out mathematically what to do with that info to check if the guard is facing towards the sprite.Any ideas? - Goishin   
  One possibility would be to generate a triangle, spreading out from the "guard's" location, in the same direction that he is facing.  Test for collision of your character with the guard's "view-triangle".   ;Quote:Original post by GoishinI'm trying to determine mathematically how one sprite can see another sprite. I have a guard object, and I only want to initiate action if the guard isn't looking in a character's direction.I have the guard's position and direction, both as D3DXVector3 vectors. And I have the sprite's (the non-guard units) position and direction vectors. But I can't figure out mathematically what to do with that info to check if the guard is facing towards the sprite.Any ideas? - GoishinIf the dot product of the vector from the guard's position to the player's position and the guard's direction vector is greater than or equal to cos(half_guard_fov), then the guard is looking at them.E.g.D3DXVECTOR3 vGuardPos(1, 2, 3);   // Guard positionD3DXVECTOR3 vPlayerPos(10, 1, 27);// Player positionD3DXVECTOR3 vGuardDir(0, 0, 1);   // Normalised guard's direction vectorfloat fGuardFOV = D3DXToRadian(90.0f); // Guard's FOVD3DXVECTOR3 vToPlayer = vPlayerPos - vGuardDir;D3DXVec3Normalize(&vToPlayer, &vToPlayer);if(D3DXVec3Dot(&vToPlayer, &vGuardDir) > cosf(fGuardFOV/2.0f)){   // Guard can see player};  Wow,That was remarkably succinct. Thank you so much Evil Steve. I'm beginning to think you aren't living up to your name ;) - Goishin   