You can figure out a vector distance pretty fast if you use the dot product. The dot product of two vectors A and B is the Length(A) x Length(B) x Cos (angle between them). If you dot a vector with itself, then you get Length(A) x Length(A) x Cos(0). Cosine of zero is one, so any vector A dotted with itself is Length(A) squared. If we're doing a comparison, we can take the distance threshold, square it, and compare it to the dot product of the vector from the camera to the object and itself.

[Join us on Discord] and/or [Support us on Patreon]

Got a burning question you want answered?

- Short questions: Ask a Game Dev on Twitter
- Long questions: Ask a Game Dev on Tumblr
- Frequent Questions: The FAQ