How can I make 2D Raycast have a Vector2 direction that would always point at some Object even as it moves

How can I make 2D raycast have a Vector2 direction that would always point at some Object even as both objects move differently, for example:

Have a guard that walks on pre-set route and and also have Raycast pointing at player no matter where he moves.

Thanks in forward.

Use a LineCast : A linecast is an imaginary line between two points in world space