Hello, I didn’t use pathfinding, use the joystick operation unit to move directly, yes, I used the TAG to mark the locked grid.
_constraint = NNConstraint.Default;
_constraint.distanceXZ = true;
_constraint.constrainTags = true;
_constraint.tags = (int) WorldTag.Building;
Vector2d clampedPos = AstarPath.active.GetNearest ( nextPos, _constraint ).position;
Because the position returned by the GetNearest method is not the same as the distance from the unit position, I have length-scaled the returned position to ensure that the speed does not change when the obstacle is reached. So I feel the reason here, let the unit enter the locked area.