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 ?
↧