I have a classic exercise which asks me to check if a character was attacked from the back (backstab or projectile). I know I can use the dot product for this, I was just wondering if I had to normalize the vectors first or if it didn't matter.
My reasoning was if the vector coordinates were huge numbers, if it would cause my dot product to overflow or underflow.
float dotProd(Vector3& P, Vector3& Q)
{
return P.x * Q.x + P.y * Q.y + P.z * Q.z;
}
bool sneakAttack(Vector3& proj, Vector3& player)
{
if(dotProd(proj, player) > 0)
return true;
else
return false;
}