Hydrogen Framework  1.3.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Hydrogen.NavMesh Class Reference

Additional static functions used to extend existing NavMesh support inside of Unity. More...

Static Public Member Functions

static bool AgentAtDestination (this NavMeshAgent agent)
 Determine if NavMeshAgent is at its destination. More...
 
static Vector3 RandomPosition (Vector3 basePosition, float distance, int allowedMask=1)
 Find a random position on the NavMesh. More...
 

Detailed Description

Additional static functions used to extend existing NavMesh support inside of Unity.

Definition at line 36 of file NavMesh.cs.

Member Function Documentation

static bool Hydrogen.NavMesh.AgentAtDestination ( this NavMeshAgent  agent)
static

Determine if NavMeshAgent is at its destination.

Returns
true, if at destination was agented, false otherwise.
Parameters
agentThe target NavMeshAgent.

Definition at line 43 of file NavMesh.cs.

44  {
45  float dist = agent.remainingDistance;
46  if (!float.IsPositiveInfinity (dist) && agent.pathStatus == NavMeshPathStatus.PathComplete &&
47  agent.remainingDistance == 0f) {
48  return true;
49  }
50  return false;
51  }
static Vector3 Hydrogen.NavMesh.RandomPosition ( Vector3  basePosition,
float  distance,
int  allowedMask = 1 
)
static

Find a random position on the NavMesh.

Returns
The random position.
Parameters
basePositionA base position to use as an offset from.
distanceThe maximum allowed distance from the basePosition that the random position can be.
allowedMaskAny limitations on what NavMeshLayer the position can be on.

Definition at line 60 of file NavMesh.cs.

61  {
62  NavMeshHit _hit;
63 
64  return UnityEngine.NavMesh.SamplePosition ((Random.insideUnitSphere * distance) + basePosition,
65  out _hit, distance, allowedMask) ? _hit.position : basePosition;
66  }