Skip to main content

ViewCone

A class in Root.Township, the global namespace.

A cone along the object's forward axis, used by AI to check whether a point is in view.

Constructors​

MemberWhat it is
ViewCone()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

2 private and internal fields
MemberWhat it is
private float angleHalf-angle of the cone in degrees, from its forward axis (90 by default).
private float angleDotCosine of angle, set in OnValidate, used as a quick reject in Contains.

Properties​

MemberWhat it is
bool IsActive { get; set; }When false, Contains always returns false.

Methods​

MemberWhat it is
bool Contains(Vector3 point, out float ratio)Whether a point is inside the cone. ratio is 0 at the centre and 1 at the edge.
2 private and internal methods
MemberWhat it is
private void OnDrawGizmosSelected()Editor: draws lines around the cone's edge.
private void OnValidate()Updates angleDot to the cosine of angle.

Used in​

Members of other types that take, return or hold a ViewCone: