A little vector math problem

Project point P onto the line created by A’s forward vector. Look up how to do projection with vectors and points. The behavior of how you want to move it is entirely up to you.