Page MenuHomeFeedback Tracker

[2.20] CalculatePath No Longer Works Outside of Map Borders
New, NormalPublic

Description

Since v2.20, it appears that CalculatePath no longer works (PathCalculated event handler never fires) if used on a unit that is outside of the map borders. It seems there is a hard cutoff at about 275 meters out of the border where it suddenly stops working.

I don't know if this was part of the optimisation, but it is a regression of an important feature, since all things considered, it is perfectly valid for a unit to be placed outside of the borders. From both a mission design and AI programming perspectives, it is very useful to be able to spawn units outside of the map borders and have them move into the map, as a means to disguise spawning from players, give a bigger sense of logistics to the game and widen the useful area of the map without compromising active areas.

The combination of CalculatePath + setDriveOnPath is an especially useful tool in helping AI navigate around any challenges that may be imposed upon them when they spawn outside of the map, and it has proven essential in my AI programming. The situation I described used to work perfectly until this update.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
AI Pathfinding / Motion
Steps To Reproduce

Since most maps are surrounded by water and I would need to use boats to describe the problem with those (although that is also a perfectly valid way to observe the issue), I will use Livonia for these steps:

  1. Spawn an offroad pickup truck with an AI driver right at the lower left corner of the map, very near [0,0,0], but ensure it is inside the map (positive coordinates).
  1. Pick a valid, reachable, destination position anywhere on the map (such as [4223.11,8982.46,0], a road near Gliniska) and use the CalculatePath command as described in the wiki together with the PathCalculated EH, and add logging/hinting in the EH code to observe whether it fires.
  1. Observe the EH firing (and observe the vehicle start to move if using my sample code).
  1. doStop the truck if moving and teleport the truck to [-280, 0, 0]. Try step (2) and you will see the EH will never fire.
  1. Now teleport the truck to [-260, 0, 0]. Try step (2) and you will see the EH will immediately fire this time.

The distance may be slightly variable depending on circumstances, but it is perfectly reproduceable and quite obviously there is a hard cutoff here. Whether it works or not depends on only a few meters. The terrain, the environment, the target, everything is the same. There are no additional obstacles, but in one case it works, in the other it doesn't.

Additional Information

This is the sample code I used. It hints the path (if EH fires), and also orders the vehicle to setDriveOnPath to the target.

_dude = yourpickuptruck; 

hint "";

_agent = calculatePath [typeof vehicle _dude, "CARELESS", getPosASL vehicle _dude, [4223.11,8982.46,0]];  
    
 _agent setVariable ["unit",vehicle _dude];  
   
 _agent addEventHandler ["PathCalculated", {  
   
  params ["_agent", "_path"];  
    
  if ((isNull _agent) || {_agent getVariable ["pathCalculated", false]}) exitWith {};    
  _agent setVariable ["pathCalculated", true];  
   
  hint str _path; 
          
  (_agent getVariable "unit") setDriveOnPath _path; 
   
 }];

Event Timeline

K.Hunter created this task.Sun, Jul 20, 4:05 PM