Skip to content

bugfix(pathfinder): Accurate movement destinations when unobstructed#2296

Closed
stephanmeesters wants to merge 2 commits intoTheSuperHackers:mainfrom
stephanmeesters:bugfix-accurate-pathing
Closed

bugfix(pathfinder): Accurate movement destinations when unobstructed#2296
stephanmeesters wants to merge 2 commits intoTheSuperHackers:mainfrom
stephanmeesters:bugfix-accurate-pathing

Conversation

@stephanmeesters
Copy link

@stephanmeesters stephanmeesters commented Feb 11, 2026

When moving units the exact destination will be determined by pathfinding: the Pathfinder::adjustDestination will adjust a given coordinate to account for obstacles. It will however also adjust the destination when there are no obstacles and place it in the middle of a path find cell (as Mauller suspected in the linked issue).

The fix here is to use the original destination (undo the adjustment) when there is no obstruction and the player is human.

It also appears to resolve the chinook movement issue but only when the path where it lands is unobstructed.

It should be determined whether the change to group unit movement is desirable.


The videos below show the effect this fix on a single unit and on a group of units.

Demonstrate accuracy relative to mouse click

output.mp4

Pathcells debug for single unit

debug-single.mp4

Pathcells debug for a group of unit

debug-group.mp4

Pathcells debug for chinooks (fixed linked issue only if path unobstructed)

debug-chinooks.mp4

Todo

  • Replicate to Generals
  • Add comment

@Caball009
Copy link

This looks related: #1998

@Mauller
Copy link

Mauller commented Feb 12, 2026

When running a debug build, use CTRL + A to cycle through the pathfinding overlays, they will show you what tiles a unit is covering when deciding the destination. Mode 1 shows the path created, 2 shows obstructions on the map and 3 shows the cells covered by units in their current position and destination.

You need to make sure a unit is not considered to be taking up more pathfinding cells than it originally would, otherwise it will throw off pathing around that unit if you attempt to accurately place a unit where the mouse clicked compared to how the pathfinding grid is laid out.

This "issue" is likely something we don't want to change the behavior of since it can have consequences on pathfinding in various ways.

@stephanmeesters
Copy link
Author

@Mauller I have added extra video's with the pathfinding overlays, one for single units and one for a group, please have a look. As far as I can tell there are no additional cells being used. Group movement appears less clumpy.

@stephanmeesters
Copy link
Author

@Caball009

See the chinooks video, we can surely say it's related.

To be clear I don't expect this PR to pass at this point, it changes way more than I set out to do with just the linked bug. But the destination snapping to pathcells is problematic in it's own way for sure.

@stephanmeesters
Copy link
Author

stephanmeesters commented Feb 13, 2026

In the "Pathcells debug for single unit" video we can see the bomb truck in the right bottom corner sliding after the fix so that's at least one new problem and there are probably more. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit movement destination is inaccurate

3 participants