/* Check whether a point is within a cone */ public static bool CheckCone(float maxDist, float width, float angle, Vector3 coneOrigin, Vector3 pos, bool flattenToXZ) { //A unity-centric attempt at this function. if (Vector2.Distance(coneOrigin, pos) <= maxDist || maxDist == -1) //First, is it within the dist and/or is there no dist? { float angDirectlyToPos = MathFuncs.ReturnAngleTowardsVec(coneOrigin, pos, flattenToXZ); float diff = Mathf.Abs(Mathf.DeltaAngle(angDirectlyToPos, angle)); if (diff <= width) { return(true); } } return(false); }