Pawn line moving

How do I preserve a pawn position and move it to the Y-axis only? Also, if meet enemy in the middle, want to attack when come within range.
I tried Nashmesh, but it’s hard to ignore the line and go away.
For example, ignore the line on the line towards the Y-axis of 1 2 3 4 and join in the center of 2 and 3.
Please help me.

your explanation isnt very clear but between this and the other post you made which is similar, i imagine you are trying to move a character from point a to point b and if they detect an enemy along the way you want them to stop and attack the enemy. do you intend to use a behavior tree for this? if so then its not a hard system to implement. to begin you need a actor to represent the start and end locations and have a way for your character to detect enemies. in your behavior tree you will need a task for moving to and attacking the enemy which has priority over all over events. on that event you will also need a service i believe which checks if the character has a target, and when they have a target abort lower priority tasks. aside from that task you will also need one for the movement from point a to b which is lower priority and consists of a move to.

again your situation sounds similar to a moba so i would check out the stream by unreal on youtube which i linked in the other post