Draw line with mouse using LineRenderer

Recently I’m working on my 2.5D (top-down 45 °) tiny project

The perspective is like this
!

And I wanted to add a function: Player can drag the animal and draw a line with left button, and then it will follow the line.

But the problem is that I can’t figure out how to draw a correct line in game, I log out the mouse position to world position in console, but the z axis position is always different, I want to keep the world position’s z axis equals to zero, what should I do?
(To keep the click point always at the x-y grid plane)
!

I think that I can use raycast.hit.point to get the world position.

Just add a background object with collider(is trigger) at plane Z axis = 0, and then return the hit point position to screen posstion.