Need help with my melee combat "loop"

Hi Aron,

Is your path-finding system granular enough to mimic the distance management between two units? A good example of this would be this MMA fight at exactly 2:30

Notice how the two fighters rotate around a central point between them. When one sees an opening, they move in and strike, while the other backs off and defends.

I have been trying to mimic this behavior with both the AIDestinationSetter and AIPath but have been have been running into a number of issues:

Even with a specific endReachedDistance + whenCloseToDestination = CloseToDestinationMode.Stop, units still overshoot slightly when closing the gap to strike. This often results in units smashing into eachother when they both decide to attack. The overshoot distance seems arbitrary, so it’s hard for me to account for that with all the different weapon ranges I have.

Another issue I have is, after attempting to strike and then backing off, my units seem to take a step fowards before backing off. Almost as if they must walk onto the node in front of them before they’re able to move backwards. I set rotation to false during these times, so they should be simply moving to a point I’ve calculated directly behind them and just sliding on back.

I’m just wondering if maybe the system is meant for just general path-finding and not necessarily for the relatively small distances I’m dealing with during melee combat.

If it isn’t, is there a way I can temporarily disconnect these units from the A* grid while fighting and then re-connect them when finished? In that case I can write my own logic to manage melee combat specifically. Currently if I try and do that the units attempt to find their way back to the node they last moved to and…well things get weird.

Thank you for all your help so far.


This kind of movement is typically too fine and too special cased to be handled by a pathfinding system. You’d be better off using animations and custom code to handle this. You can disable the AI’s movement and pathfinding by simply disabling the component.

I actually found that the cleanest way to do this seems to be clearing any paths/transforms to follow and toggle CanMove during my fight state. I tried disabling the AIDestinationSetter and AIPath components but when I re-activated them, pathfinding no longer worked.

CanMove works though! Thanks.