Moving player in camera direction

First I am a little bit sorry because it is a very classical question but actually I did not find an appropriate answer to my problem which is:

I want my player to take the camera direction when moving fwd and bwd. So I could do:

Vector3 targetDirection = Camera.main.transform.forward;

Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);

It works but this way it does not move horitontally.
This could be solved by catching horizontal and vertical axis:
Vector3 targetDirection = new Vector3(horizontal, 0f, vertical);

But now my player does not follow camera direction.
Any idea ?

A bit more of your code would be helpful for answering. I I’m assuming that your camera is tilted downward? If so you can solve your problem this way:

Vector3 targetDirection = Camera.main.transform.forward;
targetDirection.y = 0.0f;
targetDirection.Normalize();  
Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);

The Normalize() is only necessary if you are going to use targetDirection in some sort of movement code. If targetDirection is only used for rotation, then the Normalize() can be removed.