Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetAreaCost(int)

Gets the cost for path calculation when crossing area of a particular type.
Read time 1 minuteLast updated 12 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine.AI
  • Assembly: UnityEngine.AIModule
public float GetAreaCost(int areaIndex)

Parameters

areaIndex

Area Index.

Returns

Type

Description

floatCurrent cost for specified area index.

Remarks

The cost of a path is the amount of "difficulty" involved in calculating it - the shortest path may not be the best if it passes over difficult ground, such as mud, snow, etc. Different types of areas are denoted by navmesh areas in Unity. The cost of a particular area is given in cost units per distance unit. Note that the cost of a path applies to the pathfinding only and does not automatically affect the movement speed of the agent when following the path. Indeed, the path's cost may denote other factors such as danger (safe but long path through a minefield) or visibility (long path that keeps a character in the shadows).