public int GetUnitNearestNodeID(UnitCreep unit) { NodeTD n1 = platform.GetNearestNode(unit.GetTargetPos(), 1); //get walkable only NodeTD n2 = platform.GetNearestNode(unit.GetLastTargetPos(), 1); return((Vector3.Distance(unit.GetPos(), n1.pos) > Vector3.Distance(unit.GetPos(), n2.pos)) ? n2.ID : n1.ID); }