map.pathFindingHeightMap: the grayscale texture (heightmap) used for path-finding purposes. Used to determine if there’s water or land (and it’s altitude). Only the red channel is used (0-255).
map.pathFindingWaterLevel: determines the value of the path-finding heightmap under which it’s considered water.
map.pathFindingHeuristicFormula: formula for estimating cost from a given position to destination.
map.pathFindingMaxCost: maximum accumulated cost for finding routes. You can increase this value to return longer routes at performance expense. Default max value is 2000 cost points.
map.pathFindingMaxSteps: maximum number of steps for any route You can increase this value to return longer routes at performance expense. Default max value is 2000 steps.
map.FindRoute: finds the optimal route between two locations. There’re several overloads with different options.
map.FindRouteAsCoroutine: same but it’s a non-blocking version which runs in a background thread. Note that the system doesn’t allow to run two or more calls on FindRoute so you have to avoid that. The public field “findRouteIsBusy” let you know if there’s an ongoing path-finding operation.
Open World (non-grid based) movement pathfinding functions
map.pathFindingEnableCustomRouteMatrix: set this property to true to enable custom location costs. This will allow the usage of functions below to modify the custom route matrix. Basically the values in this matrix are added to the calculated crossing cost of the path finding engine for that location (a 0 will not add any cost).
map.PathFindingCustomRouteMatrixReset(): call this function to clear/reset current custom route matrix. Usually you call this function before populating the route matrix with your own custom values.
map.PathFindingCustomRouteMatrix (get/set): returns a copy of the current custom route matrix (or set it with a provided matrix). This is useful to store different cost matrix for each player and restore it at the start of each player’s turn.
map.PathFindingCustomRouteMatrixSet (position, cost): specifies movement cost for a given map position.
map.PathFindingCustomRouteMatrixSet (List<Vector2> positions, cost): specifies movement cost for a list of map position. A cost of 0 means unbreakable position.
map.PathFindingCustomRouteMatrixSet (region, cost): specifies movement cost for a region (eg. a province or country region). A cost of 0 means unbreakable position.
map.PathFindingCustomRouteMatrixSet (province, cost): specifies movement cost for a province. A cost of 0 means unbreakable position.
map.PathFindingCustomRouteMatrixSet (country, cost): specifies movement cost for a country. A cost of 0 means unbreakable position.
map.PathFindingCustomRouteMatrixSet (country, cost): specifies movement cost for a country. A cost of 0 means unbreakable position.
map.PathFindingPrewarmCountryPositions(): pre-computes the matrix positions within each country region. This method is called automatically during startup if the Prewarm option is enabled in the inspector. Enabling Prewarm or calling this method in start up of your game will avoid any hiccup the first time the PathFindingCustomRouteMatrixSet methods are used.
map.FindRoute(startPosition, endPosition, terrainCapability, minAltitude, maxAltitude): returns an optimal route from startPosition to endPosition as a list of map positions (Vector2) having into account terrain capability, minimum altitude and maximum altitude options. The terrain capability “Air” takes into account custom costs but let the unit fly over the ocean.
map.PathFindingGetProvincesInPath(path): returns a list of provinces indices being crossed by a path.
map.PathFindingGetCountriesInPath(path): returns a list of countries indices being crossed by a path.
map.PathFindingGetCitiesInPath(path): returns a list of cities indices being crossed by a path.
map.PathFindingGetMountPointsInPath(path): returns a list of mount points indices being crossed by a path.
Country to Country pathfinding functions
map.FindRoute(startCountry, destinationCountry, …): returns a list of Country objects that connect startCountry with destinationCountry including them.
Province to Province pathfinding functions
map.FindRoute(startProvince, destinationProvince, …): returns a list of Country objects that connect startCountry with destinationCountry including them.
Hexagonal Grid pathfinding functions
map.FindRoute(startCell, destinationCell, …): returns a list of cell indices that connect two cells.
map.PathFindingCellSetSideCost(cell, side, cost): sets a crossing cost for a cell’s side.
map.PathFindingCellSetAllSidesCost(cell, cost): sets a crossing cost for all cell’s sides.
map.PathFindingCellSetAllSidesCost(cell1, cell2, cost): sets a crossing cost between cell1 and cell2.
map.PathFindingGetSideCost(cell1, side, cost): gets the crossing cost for that cell’s side.
map.PathFindingCustomCellCosts (get/set): returns a copy of the current custom cell costs (or set it with a provided array). This is useful to store different cost configuration for the entire grid for each player and restore it at the start of each player’s turn or prior an unit movement which uses different values.