Replaced strange algebra with dot product.
10 degrees is a completely arbitary constant I pulled from nowhere. Feel free to adjust this value.
This commit is contained in:
parent
5d4f70a7a5
commit
0690788cdf
@ -42,12 +42,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
Direction.Normalize();
|
||||
|
||||
Vector3d LookVector = a_Player->GetLookVector();
|
||||
LookVector.Normalize();
|
||||
double dot = Direction.Dot(LookVector);
|
||||
|
||||
if ((Direction - LookVector).SqrLength() > 0.02)
|
||||
// 0.09 rad ~ 5 degrees.
|
||||
// If the players crosshars are 10 degrees from the line linking the endermen
|
||||
// It counts as looking.
|
||||
if (dot > cos(0.09))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -140,4 +142,4 @@ void cEnderman::EventLosePlayer()
|
||||
super::EventLosePlayer();
|
||||
m_bIsScreaming = false;
|
||||
GetWorld()->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user