# AI Pathing Cost Unit

Grammar — Pathing cost for unit unit to point to, considering buildings of type type
FlagsNative | Function

Returns the pathing cost from a unit.

# Arguments

Returns — int

native int AIPathingCostUnit(
	unit u,
	point to,
	bool ignoreEnemyBuildings,
);

Category: AI Advanced / Utility / Functions

# Examples

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:3767

            if (lv_currentattacktargetunit == null) { break; }
            if ((libNtve_gf_UnitCanCreateEffectOnUnit(lv_currentattacktargetunit, "ThreatTest", lp_attacker) == true) && ((UnitFilterMatch(lv_currentattacktargetunit, UnitGetOwner(lp_attacker), UnitFilter(0, 0, (1 << c_targetFilterCloaked), 0)) == true) || (libNtve_gf_UnitIsVisibleToPlayer(lv_currentattacktargetunit, UnitGetOwner(lp_attacker)) == true))) {
                lv_currentpathingdistance = AIPathingCostUnit(lp_attacker, UnitGetPosition(lv_currentattacktargetunit), c_ignoreEnemyBuildings);
                if ((lv_currentpathingdistance < lp_satisfiedPathingDistance)) {
                    lv_bestattacktargetunit = lv_currentattacktargetunit;

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:4283

            if ((PathingType(lv_spawnLocation) == c_pathingGround) && (PointPathingIsConnected(lv_spawnLocation, PlayerStartLocation(1)) == true)) {
                UnitSetPosition(lv_birthingUnit, lv_spawnLocation, false);
                if ((AIPathingCostUnit(lv_birthingUnit, PlayerStartLocation(1), c_ignoreEnemyBuildings) > 0)) {
                    break;
                }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:5741

    }

    TriggerDebugOutput(1, IntToText(AIPathingCostUnit(UnitGroupUnit(UnitGroupSelected(1), 1), PlayerStartLocation(1), c_ignoreEnemyBuildings)), true);
    return true;
}

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1579

	if ((TechTreeUpgradeCount(player, c_ZR_RoachUnderground, c_techCountCompleteOnly) > 0)) {
		
		if (AIPathingCostUnit (aiUnit, AIWaveGoal(AIUnitGetWave(aiUnit)), true) < 0) {
			return;
		}			

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1604

	if (TechTreeUpgradeCount(player, c_ZR_RoachUnderground, c_techCountCompleteOnly) > 0) {
		
		if (AIPathingCostUnit (aiUnit, AIWaveGoal(AIUnitGetWave(aiUnit)), true) < 0) {
			return;
		}