Stop movement when distance between two actors is too big

What is a good method of stopping pawn movement when it is too far away from another pawn? I have two pawns which I can move on the map by hitting somewhere on the map with LMB. I don’t want them to get too far away from each other. I had a few ideas, but perhaps there is easier solution. First, I thought about simple checking the distance between two pawns and if it’s greater than, let’s say, 1000 I call SimpleStopMovement method. This doesn’t work good, because when I stop movement, the distance stays >1000 and my pawn won’t move when I hit LMB again somewhere on the map. Then I thought about adding two blocking volumes to my pawns, but there’s no way for making one blocking volume block just one pawn, and the second block the second pawn. I also thought about this: when I hit LMB I first check if the distance between hit location and the second pawn is greater then 1000. If not, then I just simple move the pawn to the hit location. But if yes, I calculate a new vector point on the path between the first pawn and the original hit location which distance to the second pawn is actually 1000. Calculating this point seems a little too hard for this problem, so I thought I’d ask here, if there’s an easier solution.

I’d set a bool like “DistanceTooFar” after checking the distance on LMB.

Then, I’d use a branch to only allow player movement if the bool is false.

Just set it up so the bool gets set on each LMB click event and you should not have any issues.

It’s actually exactly what I have now. But the pawn should move even if hit location is too far from another pawn, just stop movement when the distance between two pawns is greater than 1000. Until then pawns should move.

Ah, I see what you are driving at. Maybe you can get the LMB location and then move the pawn towards it till the pawn has moved 1000 feet?

You could set up a spherical, invisible, and non-collision volume attached to one or both of them, and stop the movement of the other pawn with an End Overlap event, filtered by the class of the other pawn. On Begin Overlap, they can move again. This would prevent having to do a constant distance check.